/* Sete Noites — casca da página. O tabuleiro é Canvas (src/render.js); aqui
   ficam o Espetáculo, os botões, o tutorial, a ajuda e as telas de fim.
   Direção: capa de edição especial — vinho profundo, dourado de folha, branco
   e preto. O dourado nunca é chapado: é um degradê de claro a escuro. */

@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("public/fonts/cinzel-latin-wght.woff2") format("woff2");
}

:root {
  --bg: #5e1123;
  --deep: #2e0610;
  --white: #fbf3df;
  --quiet: rgba(251, 243, 223, 0.68);
  --gold: #dcae4f;
  --gold-light: #f8e7ad;
  --gold-dark: #9d6c20;
  --line: rgba(220, 174, 79, 0.6);
  --foil: linear-gradient(168deg, #f8e7ad 0%, #e5bd62 30%, #b4802b 62%, #e9c871 100%);
  --veil: rgba(46, 6, 16, 0.94);
  --caps: "Cinzel", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--white);
  font-family: var(--serif);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
#jogo {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}
.ouro {
  background: var(--foil);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hud {
  position: fixed;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(22px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(26px, env(safe-area-inset-left));
  pointer-events: none;
}
/* o Espetáculo é o branco mais vivo da tela: faz barulho de propósito */
.espetaculo {
  margin: 0;
  color: #fffaf0;
  line-height: 1;
  font-family: var(--caps);
  text-shadow: 0 1px 10px rgba(255, 240, 210, 0.35);
  transition: opacity 900ms ease, color 900ms ease;
}
.espetaculo span {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.espetaculo strong {
  display: inline-block;
  font-size: clamp(1.9rem, 8.6vw, 2.7rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transform-origin: left center;
}
/* no fim, o barulho se cala */
body:not([data-fase="playing"]) .espetaculo { color: var(--quiet); opacity: 0.5; text-shadow: none; }
body[data-fase="licao"] .espetaculo { visibility: hidden; }
.espetaculo strong.pula { animation: pula 420ms cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pula {
  0% { transform: scale(1); }
  35% { transform: scale(1.38) rotate(-3deg); }
  100% { transform: scale(1); }
}

button {
  font: inherit;
  font-family: var(--caps);
  letter-spacing: 0.06em;
  color: var(--gold-light);
  background: rgba(28, 2, 9, 0.35);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 20px;
  cursor: pointer;
}
button:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }
button:active { background: var(--gold); color: var(--deep); }
button.discreto { border-color: transparent; background: transparent; color: var(--quiet); font-family: var(--serif); letter-spacing: 0; }

.botoes { display: flex; gap: 0; pointer-events: auto; }
.botoes button {
  position: relative;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--gold);
  display: grid;
  place-items: center;
}
.botoes svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.botoes svg .cheio { fill: currentColor; }
/* desligado: mais apagado e riscado */
.botoes button[aria-pressed="false"] { opacity: 0.45; }
.botoes button[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 1.5px;
  background: currentColor;
  transform: rotate(-45deg);
}

/* frase do tutorial: acima do tabuleiro, onde o olho passa antes do dedo */
#licao {
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
#licao[hidden], #licao-pe[hidden] { display: none; }
#licao.por-cima { background: var(--veil); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
#licao.ao-lado { text-align: left; justify-content: flex-start; }
#licao-texto {
  margin: 0;
  font-size: clamp(1.12rem, 4.8vw, 1.4rem);
  line-height: 1.28;
  text-wrap: balance;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  transition: color 300ms ease;
}
/* a frase chega grande e dourada, depois assenta: é para ser vista */
#licao-texto.chega { animation: chega 900ms cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes chega {
  0% { opacity: 0; transform: scale(1.16); color: var(--gold-light); }
  45% { opacity: 1; transform: scale(1.08); color: var(--gold-light); }
  100% { transform: scale(1); }
}
#licao-texto.feito { color: var(--gold-light); }
#licao-texto.feito::after { content: " ✓"; }
#licao-pe {
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--gold);
  font-family: var(--caps);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
#licao-pe.ao-lado { justify-content: flex-start; flex-wrap: wrap; }
#licao-avanca { font-size: 0.95rem; padding: 0 1.6rem; text-transform: none; }
#licao-pula { font-size: 0.9rem; text-transform: none; }
#licao-avanca[hidden], #licao-pula[hidden] { display: none; }

/* telas de fim */
#fim {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  background: var(--veil);
  border: 1px solid var(--line);
  border-radius: 14px;
  animation: surge 420ms ease-out;
}
#fim[hidden] { display: none; }
@keyframes surge { from { opacity: 0; } to { opacity: 1; } }
#fim p { margin: 0; }
#fim.subiu .duas, #fim.dissolveu .subiu-corpo { display: none; }
.luz { line-height: 1; font-family: var(--caps); }
.luz span {
  display: block;
  font-size: 0.95rem;
  letter-spacing: 0.42em;
  margin-right: -0.42em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  color: var(--gold);
}
.luz strong {
  display: inline-block;
  font-size: clamp(4rem, 23vw, 6.6rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--foil);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(255, 214, 130, 0.25));
}
.pequeno { font-size: 0.82rem; color: var(--quiet); min-height: 1.1em; }
.meta { font-size: 0.95rem; color: var(--gold-light); margin-bottom: 0.25rem !important; }
.duas { font-size: clamp(1.9rem, 9vw, 2.6rem); font-style: italic; margin-bottom: 0.8rem !important; }
.fim-pe {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 0.7rem;
}
#proxima {
  font-size: 1.05rem;
  padding: 0 2rem;
  min-height: 52px;
  background: var(--foil);
  color: var(--deep);
  border-color: var(--gold-light);
  font-weight: 600;
}
#proxima[hidden] { display: none; }
#de-novo { font-size: 1.05rem; padding: 0 2rem; min-height: 48px; }
#proxima:not([hidden]) + #de-novo { font-size: 0.9rem; min-height: 44px; border-color: transparent; background: transparent; color: var(--quiet); }

/* ajuda */
#ajuda {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(30, 3, 10, 0.66);
  animation: surge 260ms ease-out;
}
#ajuda[hidden] { display: none; }
#ajuda section {
  width: min(430px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--gold);
  outline: 1px solid rgba(220, 174, 79, 0.4);
  outline-offset: 4px;
  border-radius: 14px;
  padding: 22px 22px 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
#ajuda h2 {
  margin: 0 0 0.8rem;
  font-family: var(--caps);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-align: center;
  background: var(--foil);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#ajuda ul { margin: 0 0 0.8rem; padding-left: 1.15rem; }
#ajuda li { margin-bottom: 0.5rem; line-height: 1.35; }
#ajuda li::marker { color: var(--gold); }
/* o pé fica sempre à vista: em tela baixa a lista rola, o Fechar não some */
.ajuda-pe {
  position: sticky;
  bottom: -16px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0.9rem -22px -16px;
  padding: 10px 22px 14px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
#ajuda-tutorial { padding-left: 0; }

.selo {
  position: fixed;
  inset: auto 0 max(7px, env(safe-area-inset-bottom)) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--caps);
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  pointer-events: none;
}
#selo-texto { min-height: 28px; display: flex; align-items: center; }
#fases[hidden] { display: none; }
/* as sete fases da Noite: um losango cada */
#fases { display: flex; pointer-events: auto; }
#fases:not([hidden]) { margin-top: -4px; }
#fases button {
  position: relative;
  min-width: 30px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
}
#fases button::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 9px;
  height: 9px;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 1.3px solid var(--gold);
}
#fases button.feita::before { background: var(--gold); }
#fases button.atual::before { width: 12px; height: 12px; border-color: var(--gold-light); box-shadow: 0 0 10px rgba(248, 231, 173, 0.75); }
#fases button.atual.feita::before { background: var(--gold-light); }
#fases button:disabled { opacity: 0.32; cursor: default; }
#fases button:active { background: transparent; }

.so-leitor {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .espetaculo strong.pula, #fim, #licao-texto.chega, #ajuda { animation: none; }
}
@media (max-height: 520px) {
  .espetaculo strong { font-size: 1.6rem; }
  .luz strong { font-size: 3rem; }
  .selo { display: none; }
  #licao-texto { font-size: 1.05rem; }
  #ajuda section { width: min(740px, 100%); padding-top: 14px; }
  #ajuda h2 { margin-bottom: 0.5rem; font-size: 1.05rem; }
  #ajuda ul { columns: 2; column-gap: 2.2rem; font-size: 0.92rem; }
  #ajuda li { break-inside: avoid; }
}
