/* App móvel do jogador */
body { min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: calc(6px + env(safe-area-inset-top)) 16px 6px;
  background: rgba(18,13,43,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-size: 1.3rem; margin: 0; }
/* Logótipo completo em cima e o nome do jogador por baixo */
.topbar .logo.top { height: clamp(56px, 11vh, 95px); width: auto; max-width: 100%; }
#top-user { font-size: .95rem; font-weight: 700; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#top-user:empty { display: none; }

#app { max-width: 560px; margin: 0 auto; padding: 12px 16px; }
.screen { display: none; }
.screen.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.center { text-align: center; }
.small { font-size: .85rem; }
.small-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; margin: 22px 0 8px; }

.list { display: grid; gap: 8px; }
.list-row { display: flex; gap: 6px; }
.list-row .btn.block { flex: 1; justify-content: flex-start; word-break: break-all; text-align: left; }
#s-settings .btn.block { margin-top: 10px; }



.join { display: flex; gap: 8px; }
.join input { text-transform: uppercase; letter-spacing: .3em; font-size: 1.4rem; font-weight: 800; text-align: center; }

/* Jogo */
.game-top { display: flex; justify-content: space-between; gap: 8px; }
.exit-link { background: none; border: 0; color: inherit; opacity: .4; font: inherit; font-size: .8rem; padding: 6px 8px; cursor: pointer; }
body[data-phase="finished"] .exit-link { display: none; }
.answer.selected { outline: 3px solid #fff; outline-offset: -3px; }
.change-hint { font-size: .85rem; margin-top: 6px; }
.pill { background: var(--card); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
#g-score { color: var(--accent); }
.timer { height: 8px; background: rgba(255,255,255,.08); border-radius: 999px; margin: 8px 0 10px; overflow: hidden; }
#g-timer { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--accent)); }
#g-timer.low { background: var(--bad); }

.panel { display: none; }
.panel.active { display: block; animation: fade .25s ease; }
.big-emoji { font-size: 4.5rem; margin: 20px 0 6px; }
.qtext { font-size: 1.2rem; line-height: 1.22; margin: 2px 0 12px; text-align: center; }
.answers { display: grid; gap: 8px; }
.answer {
  display: flex; align-items: center; gap: 12px;
  font: inherit; font-weight: 800; font-size: 1.1rem; color: #fff; text-align: left;
  background: var(--opt); border: 0; border-radius: 14px;
  padding: 10px 12px; min-height: 56px; cursor: pointer;
  text-shadow: 0 1px 4px rgba(0,0,0,.35);
  transition: transform .08s;
}
.answer:active { transform: scale(.97); }
.answer .letter { background: rgba(0,0,0,.25); border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; flex: none; }
.points { font-size: 1.5rem; font-weight: 900; color: var(--accent); margin: 6px 0; }
.rank-big { font-size: 4.5rem; font-weight: 900; color: var(--accent); line-height: 1; }
#s-game.good { box-shadow: inset 0 0 0 9999px rgba(46,204,113,.08); }
#s-game.bad { box-shadow: inset 0 0 0 9999px rgba(255,77,77,.08); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 16px; }
.chip { background: var(--card); border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; font-size: .85rem; }
.mini-board { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 6px; text-align: left; }
.mini-board li { display: flex; justify-content: space-between; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.mini-board li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-board li.me { border-color: var(--accent); }
.mini-board .mb-name { flex: 1; min-width: 0; }
.mini-board .mb-delta { flex: none; color: var(--ok); font-weight: 800; }
.offline { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; background: var(--bad); text-align: center; padding: 8px; font-weight: 700; }

/* Pedido do código: ecrã minimalista, sem barra de cima (igual ao da TV) */
body[data-screen="code"] .topbar { display: none; }
#s-code.active { display: flex; flex-direction: column; justify-content: center; min-height: 90vh; }
#s-code .pick { width: 100%; }
/* Classificação entre perguntas: tamanhos à medida da altura, para o top 10 caber sem scroll */
body[data-screen="game"][data-phase="leaderboard"] .topbar { padding-top: calc(3px + env(safe-area-inset-top)); padding-bottom: 3px; }
body[data-screen="game"][data-phase="leaderboard"] .topbar .logo.top { height: clamp(26px, 6dvh, 60px); }
body[data-screen="game"][data-phase="leaderboard"] #app { padding-top: 6px; padding-bottom: 6px; }
#g-board p { margin: 0; }
#g-board .rank-big { font-size: clamp(1.8rem, 7dvh, 4.5rem); }
#g-board .points { font-size: clamp(.95rem, 3.2dvh, 1.5rem); }
#g-top { margin: clamp(4px, 1dvh, 18px) 0 0; gap: clamp(2px, .5dvh, 6px); }
#g-top li { padding: clamp(2px, .7dvh, 8px) 10px; font-size: clamp(.7rem, 2.4dvh, 1rem); line-height: 1.2; }
/* Ecrãs muito baixos: tira o que já se vê noutro sítio */
@media (max-height: 520px) {
  body[data-screen="game"][data-phase="leaderboard"] .topbar { display: none; }
}
@media (max-height: 420px) {
  #g-board p { display: none; }
}
/* Criar jogo (igual a /novojogo) */
.or-create { text-align: center; margin: 12px 0 8px; }
.btn.create { justify-content: center; background: var(--ok); color: #06240f; border-color: transparent; }
/* Barra "Instalar app" */
.install-bar { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 50; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.4); font-size: .9rem; }
.install-bar span { flex: 1; }
/* Fim do jogo: certas e erradas */
.tally .ok { color: var(--ok); }
.tally .bad { color: var(--bad); }
