/* Ouve Lá — azulejo e papel impresso.
   Claro: papel creme, tinta azul-cobalto. Escuro: noite azul, tinta creme. */

:root {
  --papel: #efe9dc;
  --papel-2: #f7f3ea;
  --papel-3: #e3dbc9;
  --tinta: #16233f;
  --tinta-2: #5c6478;
  --cobalto: #2a5db0;
  --cobalto-claro: #4a7fd4;
  --tijolo: #b4402c;
  --verde: #2c7a52;
  --ocre: #b9822b;
  --regua: #cfc5ae;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Helvetica Neue", -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --papel: #101a2e;
    --papel-2: #16223a;
    --papel-3: #1d2b47;
    --tinta: #ece4d3;
    --tinta-2: #8f9bb4;
    --cobalto: #6b9de8;
    --cobalto-claro: #8fb8f0;
    --tijolo: #e0705a;
    --verde: #5cc38b;
    --ocre: #e0a94a;
    --regua: #2b3a5a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 20px max(28px, env(safe-area-inset-bottom));
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* Padrão de azulejo, muito ténue, atrás de tudo. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%232a5db0' stroke-width='1.1'%3E%3Cpath d='M30 2 46 18 30 34 14 18Z'/%3E%3Cpath d='M30 12 36 18 30 24 24 18Z'/%3E%3Cpath d='M0 32 14 46 0 60M60 32 46 46 60 60M30 40 44 54 30 68 16 54Z'/%3E%3C/g%3E%3C/svg%3E");
}

/* --- cabeçalho --- */

.topo {
  width: 100%;
  max-width: 540px;
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: end;
  gap: 10px;
  padding: 26px 0 14px;
  border-bottom: 2px solid var(--tinta);
}

.topo h1 a { color: inherit; text-decoration: none; }

.topo h1 {
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-size: 2.05rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.015em;
}

.topo .sub {
  display: block;
  margin-top: 7px;
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cobalto);
}

.icone {
  width: 30px; height: 30px;
  margin-bottom: 3px;
  border: 1.5px solid var(--regua);
  border-radius: 50%;
  background: transparent;
  color: var(--tinta-2);
  font-family: var(--serif);
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.icone:hover { border-color: var(--cobalto); color: var(--cobalto); }

main { width: 100%; max-width: 540px; }

.dia {
  text-align: center;
  margin: 14px 0 22px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--tinta-2);
}
.dia span { font-style: normal; font-weight: 600; color: var(--tinta); }

/* --- leitor --- */

.leitor { text-align: center; }

.barra {
  position: relative;
  height: 30px;
  border: 1.5px solid var(--tinta);
  background: transparent;
  overflow: hidden;
}

.barra-desbloqueada {
  position: absolute; inset: 0 auto 0 0;
  width: 0;
  background: var(--cobalto);
  transition: width .4s cubic-bezier(.2,.7,.3,1);
}
/* Riscado diagonal: lê-se como "gravado", não como barra de progresso de app. */
.barra-desbloqueada::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    -45deg, transparent 0 5px, rgba(255,255,255,.16) 5px 10px);
}

.barra-cursor {
  position: absolute; top: 0; bottom: 0;
  width: 2px;
  background: var(--tijolo);
  left: 0;
  opacity: 0;
}
.barra-cursor.ativo { opacity: 1; }

.marcas { position: absolute; inset: 0; pointer-events: none; }
.marcas i {
  position: absolute; top: 0; bottom: 0;
  width: 1.5px;
  background: var(--tinta);
  opacity: .35;
}

.tempos {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--tinta-2);
}

.play {
  width: 78px; height: 78px;
  margin: 24px auto 0;
  display: grid; place-items: center;
  border: 2px solid var(--tinta);
  border-radius: 50%;
  background: var(--tinta);
  color: var(--papel);
  cursor: pointer;
  transition: transform .14s ease, background .14s, color .14s;
}
.play:hover { transform: scale(1.04); background: var(--cobalto); border-color: var(--cobalto); }
.play:active { transform: scale(.97); }
.play:disabled { opacity: .35; cursor: progress; }
.play svg { width: 32px; height: 32px; fill: currentColor; margin-left: 2px; }

.dica {
  margin: 16px 0 0;
  font-family: var(--serif);
  font-size: 1rem;
  font-style: italic;
  color: var(--tinta-2);
}
.dica strong { font-style: normal; font-weight: 600; color: var(--tinta); }

/* --- tentativas: linhas de pauta, não cartões --- */

.tentativas {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  border-top: 1px solid var(--regua);
}

.tentativas li {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--regua);
  font-size: 0.93rem;
  line-height: 1.3;
}

.tentativas li.vazia { color: transparent; }
.tentativas .marca { flex: none; width: 15px; font-family: var(--serif); font-size: 1rem; text-align: center; }
.tentativas .rotulo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tentativas .nota {
  flex: none;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ocre);
}

.tentativas li.errada .marca { color: var(--tijolo); }
.tentativas li.errada .rotulo { color: var(--tinta-2); text-decoration: line-through; text-decoration-color: var(--tijolo); }
.tentativas li.saltada .marca { color: var(--tinta-2); }
.tentativas li.saltada .rotulo { color: var(--tinta-2); font-style: italic; }
.tentativas li.certa { background: color-mix(in srgb, var(--verde) 12%, transparent); }
.tentativas li.certa .marca { color: var(--verde); }
.tentativas li.certa .rotulo { font-weight: 600; }

/* --- palpite --- */

.palpite { margin-top: 22px; }
.campo { position: relative; }

#pesquisa {
  width: 100%;
  padding: 14px 40px 14px 14px;
  border: 1.5px solid var(--tinta);
  border-radius: 0;
  background: var(--papel-2);
  color: var(--tinta);
  font-family: var(--sans);
  font-size: 1rem;
}
#pesquisa::placeholder { color: var(--tinta-2); }
#pesquisa:focus { outline: none; border-color: var(--cobalto); box-shadow: 3px 3px 0 var(--cobalto); }

.limpar {
  position: absolute; right: 5px; top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  border: none;
  background: transparent;
  color: var(--tinta-2);
  font-size: 0.9rem;
  cursor: pointer;
}
.limpar:hover { color: var(--tijolo); }

.sugestoes {
  position: absolute;
  z-index: 20;
  top: calc(100% + 5px); left: 0; right: 0;
  max-height: 260px;
  overflow-y: auto;
  margin: 0; padding: 0;
  list-style: none;
  background: var(--papel-2);
  border: 1.5px solid var(--tinta);
  box-shadow: 5px 5px 0 color-mix(in srgb, var(--tinta) 18%, transparent);
}

.sugestoes li {
  padding: 10px 13px;
  border-bottom: 1px solid var(--regua);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.3;
}
.sugestoes li:last-child { border-bottom: none; }
.sugestoes li:hover, .sugestoes li[aria-selected="true"] { background: var(--cobalto); color: #fff; }
.sugestoes li:hover .s-artista, .sugestoes li[aria-selected="true"] .s-artista { color: rgba(255,255,255,.8); }
.sugestoes .s-titulo { display: block; font-weight: 600; }
.sugestoes .s-artista { display: block; color: var(--tinta-2); font-size: 0.77rem; margin-top: 2px; }
.sugestoes .nada { color: var(--tinta-2); cursor: default; font-style: italic; }
.sugestoes .nada:hover { background: none; color: var(--tinta-2); }

.acoes { display: flex; gap: 10px; margin-top: 12px; }

.acoes button {
  flex: 1;
  padding: 14px 10px;
  border: 1.5px solid var(--tinta);
  border-radius: 0;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.acoes button:hover:not(:disabled) { transform: translate(-2px,-2px); box-shadow: 3px 3px 0 var(--tinta); }
.acoes button:active:not(:disabled) { transform: none; box-shadow: none; }

.passar { background: transparent; color: var(--tinta); }
.passar span { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--tinta-2); }
.adivinhar { background: var(--tinta); color: var(--papel); }
.adivinhar:disabled { opacity: .3; cursor: not-allowed; }

/* --- fim de jogo --- */

.fim { margin-top: 30px; text-align: center; }

.veredicto {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 400;
}
.veredicto.ganhou { color: var(--verde); }
.veredicto.perdeu { color: var(--tijolo); }

.cartao {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  padding: 16px;
  border: 1.5px solid var(--tinta);
  background: var(--papel-2);
  box-shadow: 6px 6px 0 var(--cobalto);
}
.cartao img { flex: none; background: var(--papel-3); object-fit: cover; }
.cartao > div { min-width: 0; }
.cartao .titulo { margin: 0; font-family: var(--serif); font-size: 1.25rem; line-height: 1.15; }
.cartao .artista { margin: 4px 0 10px; color: var(--tinta-2); font-size: 0.87rem; }
.cartao a {
  color: var(--cobalto);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1.5px solid currentColor;
}
.cartao a:hover { color: var(--tijolo); }

.grelha { font-size: 1.45rem; letter-spacing: 5px; margin: 26px 0 14px; }

.partilhar {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--tinta);
  background: var(--cobalto);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.partilhar:hover { transform: translate(-2px,-2px); box-shadow: 3px 3px 0 var(--tinta); }

.proxima {
  margin: 20px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--tinta-2);
}
.proxima strong { font-style: normal; font-variant-numeric: tabular-nums; color: var(--tinta); }

.globais { margin-top: 32px; text-align: left; }
.globais h3, #modal-stats h3 {
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--tinta);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.globais .total {
  margin: 12px 0 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.83rem;
  color: var(--tinta-2);
}

/* --- distribuição --- */

.dist { display: grid; gap: 4px; }
.dist-linha { display: grid; grid-template-columns: 16px 1fr; gap: 9px; align-items: center; font-size: 0.78rem; }
.dist-linha b { font-family: var(--serif); color: var(--tinta-2); font-weight: 400; text-align: right; }
.dist-barra { position: relative; height: 21px; background: var(--papel-3); }
.dist-barra i {
  position: absolute; inset: 0 auto 0 0;
  background: var(--papel-3);
  min-width: 4px;
  transition: width .45s cubic-bezier(.2,.7,.3,1);
}
.dist-barra i.cheia { background: var(--cobalto); }
.dist-barra i.destaque { background: var(--verde); }
.dist-barra span {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  font-size: 0.7rem; font-variant-numeric: tabular-nums; color: var(--tinta);
}

/* --- modais --- */

dialog {
  width: min(420px, calc(100vw - 34px));
  padding: 26px;
  border: 2px solid var(--tinta);
  border-radius: 0;
  background: var(--papel-2);
  color: var(--tinta);
  box-shadow: 9px 9px 0 var(--cobalto);
}
dialog::backdrop { background: color-mix(in srgb, var(--tinta) 62%, transparent); }
dialog h2 { margin: 0 0 16px; font-family: var(--serif); font-size: 1.45rem; font-weight: 400; }
dialog form { margin-top: 22px; text-align: right; }
dialog form button {
  padding: 10px 20px;
  border: 1.5px solid var(--tinta);
  background: transparent;
  color: var(--tinta);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
dialog form button:hover { background: var(--tinta); color: var(--papel); }

.regras { margin: 0; padding-left: 18px; line-height: 1.7; font-size: 0.92rem; }
.regras li { padding-left: 4px; }
.regras::marker { font-family: var(--serif); }
.nota { margin: 16px 0 0; font-family: var(--serif); font-style: italic; font-size: 0.8rem; color: var(--tinta-2); }

.resumo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 26px; }
.resumo div { text-align: center; }
.resumo b { display: block; font-family: var(--serif); font-size: 1.7rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.resumo span { font-size: 0.58rem; font-weight: 600; letter-spacing: 0.11em; text-transform: uppercase; color: var(--tinta-2); }

/* --- estados --- */

.carregar, .erro {
  margin-top: 56px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--tinta-2);
}
.erro {
  color: var(--tijolo);
  max-width: 440px;
  padding: 18px 20px;
  border: 1.5px solid var(--tijolo);
  background: color-mix(in srgb, var(--tijolo) 8%, transparent);
}

.erro .tentar {
  display: block;
  margin: 14px auto 0;
  padding: 9px 18px;
  border: 1.5px solid var(--tinta);
  background: transparent;
  color: var(--tinta);
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.erro .tentar:hover { background: var(--tinta); color: var(--papel); }

.erro-pagina {
  margin: 60px auto;
  max-width: 440px;
  text-align: center;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--tinta-2);
}
.erro-pagina a {
  color: var(--cobalto);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1.5px solid currentColor;
}
.erro-pagina a:hover { color: var(--tijolo); }

footer {
  margin-top: auto;
  padding-top: 46px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.76rem;
  color: var(--tinta-2);
  text-align: center;
}
footer a { color: var(--cobalto); }

@media (max-width: 380px) {
  .topo h1 { font-size: 1.7rem; }
  .play { width: 68px; height: 68px; }
  .cartao { gap: 12px; padding: 13px; }
  .cartao img { width: 76px; height: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- apoio --- */

.apoio {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--regua);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.86rem;
  color: var(--tinta-2);
  line-height: 1.6;
}

.apoio a {
  display: inline-block;
  margin-top: 2px;
  color: var(--cobalto);
  font-style: normal;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1.5px solid currentColor;
}
.apoio a:hover { color: var(--tijolo); }

/* --- arquivo --- */

.ligacao {
  padding: 0;
  border: none;
  border-bottom: 1px solid currentColor;
  background: none;
  color: var(--cobalto);
  font-family: var(--serif);
  font-style: italic;
  font-size: inherit;
  cursor: pointer;
}
.ligacao:hover { color: var(--tijolo); }

.aviso-arquivo {
  margin: -12px 0 22px;
  padding: 9px 12px;
  border-left: 3px solid var(--ocre);
  background: color-mix(in srgb, var(--ocre) 13%, transparent);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.87rem;
  text-align: center;
}
.aviso-arquivo a { color: var(--cobalto); }

.arquivo {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px;
}

.arquivo button {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  gap: 1px;
  border: 1.5px solid var(--regua);
  background: transparent;
  color: var(--tinta);
  font-family: var(--serif);
  font-size: 1.05rem;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.arquivo button:hover { border-color: var(--cobalto); background: color-mix(in srgb, var(--cobalto) 9%, transparent); }
.arquivo button.hoje { border-color: var(--tinta); border-width: 2px; }
.arquivo button.ganho { background: color-mix(in srgb, var(--verde) 17%, transparent); border-color: var(--verde); }
.arquivo button.perdido { background: color-mix(in srgb, var(--tijolo) 14%, transparent); border-color: var(--tijolo); }
.arquivo button small {
  font-family: var(--sans);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--tinta-2);
}
.arquivo button.ganho small { color: var(--verde); }
.arquivo button.perdido small { color: var(--tijolo); }

.nota-topo {
  margin: -6px 0 16px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.83rem;
  color: var(--tinta-2);
}

/* --- barra do modo de teste (só com OUVELA_DEV=1) --- */

.dev {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0 -20px;
  padding: 8px 20px;
  background: var(--ocre);
  color: #1a1408;
  font-size: 0.72rem;
}

.dev span { font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }

.dev button {
  padding: 5px 11px;
  border: 1.5px solid #1a1408;
  background: transparent;
  color: inherit;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.dev button:hover:not(:disabled) { background: #1a1408; color: var(--ocre); }
.dev button:disabled { opacity: .4; cursor: not-allowed; }
