/* Controle do QuizTV no celular.
 *
 * Mesma linguagem visual do canal Roku: fundo #0f0d26 com os dois radiais e as
 * listras diagonais, gold #f4b400 como cor de acao, Anton no display e Poppins
 * no corpo. A diferenca e que aqui o navegador faz canto arredondado, gradiente
 * e sombra sozinho -- no SceneGraph cada um desses virou um PNG.
 *
 * A tela e a mao de uma pessoa em pe numa sala: alvo grande, contraste alto e
 * nada que exija precisao. */

@font-face {
  font-family: "Anton";
  src: url("fonts/Anton-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("fonts/Poppins-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("fonts/Poppins-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --bg: #0f0d26;
  --ink: #171335;
  --gold: #f4b400;
  --gold-light: #ffcc33;
  --gold-pale: #ffdc78;
  --violet: #7a6cff;

  --green: #4cd97b;
  --red: #ff5a5a;
  --correct-ring: #ffe75e;

  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.62);
  --dim: rgba(255, 255, 255, 0.38);
  --panel: rgba(255, 255, 255, 0.045);
  --panel-line: rgba(255, 255, 255, 0.09);
  --row: rgba(255, 255, 255, 0.06);

  /* Respiro que respeita notch e barra de gestos. */
  --pad-top: max(14px, env(safe-area-inset-top));
  --pad-bottom: max(14px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(90% 60% at 15% 0%, rgba(122, 108, 255, 0.2) 0%, rgba(122, 108, 255, 0) 55%),
    radial-gradient(70% 50% at 100% 100%, rgba(244, 180, 0, 0.14) 0%, rgba(244, 180, 0, 0) 60%),
    repeating-linear-gradient(
      115deg,
      rgba(255, 255, 255, 0.02) 0px,
      rgba(255, 255, 255, 0.02) 2px,
      transparent 2px,
      transparent 64px
    ),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  padding: var(--pad-top) 18px var(--pad-bottom);
  /* Sem selecao acidental: cada toque aqui e um comando, nao leitura. */
  user-select: none;
}

/* ---------- marca ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding-bottom: 14px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--gold);
  transform: rotate(-6deg);
  box-shadow: 0 3px 0 #b98600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-mark::after {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--ink);
  transform: rotate(6deg);
}

.brand-name {
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: 25px;
  letter-spacing: 1.5px;
  line-height: 1;
}

.brand-name span {
  color: var(--gold);
}

.brand-you {
  margin-left: auto;
  font-size: 13px;
  color: var(--dim);
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- telas ---------- */

main {
  flex: 1;
  min-height: 0;
  display: flex;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hidden {
  display: none;
}

.eyebrow {
  margin: 0;
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--dim);
}

.display {
  margin: 0;
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(30px, 8vw, 42px);
  line-height: 1.05;
  letter-spacing: 0.5px;
}

.muted {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.4;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

/* ---------- formulario ---------- */

input {
  width: 100%;
  padding: 17px 18px;
  font: inherit;
  font-size: 19px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--panel-line);
  border-radius: 14px;
  user-select: text;
}

input::placeholder {
  color: var(--dim);
}

input:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(244, 180, 0, 0.08);
}

.btn {
  width: 100%;
  padding: 18px;
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: 23px;
  letter-spacing: 0.5px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: var(--ink);
  box-shadow: 0 5px 0 #b98600;
}

.btn-gold:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #b98600;
}

.error {
  margin: 0;
  min-height: 1.3em;
  font-size: 14px;
  color: var(--red);
}

/* ---------- espera ---------- */

#screen-waiting {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.pulse-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(244, 180, 0, 0.5);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(244, 180, 0, 0);
  }
}

/* ---------- paineis e linhas ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}

.live {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Anton", Impact, sans-serif;
  font-size: 18px;
  color: var(--green);
}

.live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  min-height: 0;
  /* Rolagem sem barra visivel: a lista e curta e a barra polui a linha. */
  scrollbar-width: none;
}

.rows::-webkit-scrollbar {
  display: none;
}

.rows li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  background: var(--row);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
}

.rows li.is-you {
  background: rgba(244, 180, 0, 0.13);
  border-color: rgba(244, 180, 0, 0.45);
}

.rows li.is-offline {
  opacity: 0.45;
}

.row-pos {
  font-family: "Anton", Impact, sans-serif;
  font-size: 16px;
  min-width: 20px;
  color: var(--dim);
}

.row-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "Anton", Impact, sans-serif;
  font-size: 14px;
  color: var(--ink);
  flex-shrink: 0;
}

.row-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-score {
  font-family: "Anton", Impact, sans-serif;
  font-size: 15px;
  color: var(--gold);
  white-space: nowrap;
}

/* ---------- cabecalho da pergunta ---------- */

.qhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.chip {
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted);
  white-space: nowrap;
}

.stat {
  text-align: right;
  line-height: 1;
}

.stat b {
  display: block;
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: 21px;
  color: var(--gold);
}

.stat small {
  font-size: 9px;
  letter-spacing: 1.2px;
  color: var(--dim);
}

.question {
  margin: 0;
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(19px, 5vw, 26px);
  line-height: 1.25;
  flex-shrink: 0;
  /* Enunciado longo rola em vez de empurrar as alternativas pra fora da tela. */
  max-height: 26vh;
  overflow-y: auto;
  scrollbar-width: none;
  user-select: text;
}

.question::-webkit-scrollbar {
  display: none;
}

/* ---------- grade de alternativas ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.answer {
  position: relative;
  border: none;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(38px, 13vw, 64px);
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  /* A sombra dura da a impressao de botao fisico, que e o que o polegar espera. */
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
  transition:
    transform 0.08s ease,
    opacity 0.15s ease;
}

.answer:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.grid-locked .answer {
  cursor: default;
  box-shadow: none;
}

.answer.is-dim {
  opacity: 0.3;
}

.answer.is-correct {
  outline: 4px solid var(--correct-ring);
  outline-offset: -4px;
  box-shadow: 0 0 0 4px rgba(255, 231, 94, 0.35);
}

/* A escolha do jogador leva um marcador proprio: no reveal ele precisa achar a
   dele antes de entender o resultado. */
.answer.is-chosen::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 3px dashed rgba(255, 255, 255, 0.85);
  border-radius: 11px;
}

/* ---------- estado de respondido ---------- */

.lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  text-align: center;
}

.lock strong {
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: 25px;
  color: var(--gold);
}

/* ---------- veredito ---------- */

.verdict {
  margin: 0;
  padding: 13px;
  border-radius: 14px;
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: 23px;
  text-align: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.verdict.is-correct {
  background: linear-gradient(135deg, #3fd07a, #2e9e4f);
  color: #06210f;
}

.verdict.is-wrong {
  background: linear-gradient(135deg, #ff6b6b, #c73e1d);
  color: #2b0705;
}

/* ---------- cronometro ---------- */

.timer {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  flex-shrink: 0;
}

.timer i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  /* A largura vem do estado a cada poll (1s); a transicao cobre o intervalo pra
     barra andar continua em vez de pular de segundo em segundo. */
  transition:
    width 1s linear,
    background-color 0.3s ease;
}

.timer.is-mid i {
  background: var(--gold);
}

.timer.is-low i {
  background: var(--red);
}

.timer.is-paused i {
  background: var(--gold);
  opacity: 0.55;
}

.timer span {
  position: absolute;
  inset: 0;
  display: none;
}

.timer.is-hidden {
  visibility: hidden;
}

/* ---------- fim de partida ---------- */

#screen-final .score-badge {
  align-self: center;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background: var(--ink);
  border: 6px solid var(--gold);
  flex-shrink: 0;
}

.score-badge b {
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: 46px;
  line-height: 1;
  color: var(--gold);
}

.score-badge small {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--dim);
}

.rank {
  margin: 0;
  text-align: center;
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: 21px;
  color: var(--text);
  flex-shrink: 0;
}

/* ---------- aviso de rede ---------- */

.offline {
  position: fixed;
  left: 50%;
  bottom: calc(var(--pad-bottom) + 8px);
  transform: translateX(-50%);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(255, 90, 90, 0.16);
  border: 1px solid rgba(255, 90, 90, 0.4);
  color: #ffd9d9;
  font-size: 13px;
  white-space: nowrap;
}

/* Tela baixa (celular pequeno, ou teclado aberto): o que e enfeite sai antes do
   que e comando. */
@media (max-height: 620px) {
  .brand {
    padding-bottom: 8px;
  }
  .display {
    font-size: 26px;
  }
  #screen-nickname .muted {
    display: none;
  }
  .question {
    max-height: 20vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot {
    animation: none;
  }
  .answer,
  .timer i {
    transition: none;
  }
}
