/* Trivia night page. Builds on styles.css (buttons, top bar, dialogs, chat, toast). */

body.tq { height: auto; min-height: 100vh; min-height: 100dvh; overflow: auto; }
.tq-main {
  flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start;
}
.tq-create { grid-column: 1 / -1; max-width: 460px; margin: 24px auto; }
.tq-create .btn { width: 100%; }

.tq-game { min-width: 0; display: flex; flex-direction: column; gap: 10px; }

.tq-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; min-height: 40px;
  padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
}
.tq-number { color: var(--muted); font-size: 13px; }
.tq-category { font-weight: 800; color: var(--brass-2); text-align: center; font-size: 14px; }
.tq-timer { justify-self: end; font: 800 18px/1 var(--ui); font-variant-numeric: tabular-nums; min-width: 2.5em; text-align: right; }
.tq-timer.low { color: var(--bad); }
.tq-clock { height: 6px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.tq-clock i { display: block; height: 100%; width: 0; background: var(--brass); transition: width .2s linear; }
.tq-clock i.low { background: var(--bad); }

.tq-status { margin: 0; text-align: center; font-weight: 700; min-height: 1.5em; }

.tq-card {
  display: flex; flex-direction: column; gap: 14px; padding: 18px;
  border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
}
.tq-card.open { border-color: var(--brass); }
.tq-question { margin: 0; text-align: center; font: 700 22px/1.3 var(--display); overflow-wrap: anywhere; }
.tq-card.intro .tq-question { font: 500 16px/1.5 var(--ui); color: var(--muted); }

/* Four big answer buttons: two by two on wide screens, stacked on narrow phones. */
.tq-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tq-answers:empty { display: none; }
.tq-answer {
  position: relative; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 64px; padding: 10px 14px;
  border-radius: 14px; border: 2px solid transparent; color: #fff; font: 700 17px/1.25 var(--ui); text-align: left;
  cursor: pointer; transition: transform .08s, opacity .2s, box-shadow .2s;
}
.tq-answer.a0 { background: #2f6fbd; }
.tq-answer.a1 { background: #b8463c; }
.tq-answer.a2 { background: #2f8a58; }
.tq-answer.a3 { background: #8a5a1c; }
.tq-answer:not(:disabled):active { transform: scale(.98); }
.tq-answer:disabled { cursor: default; }
.tq-answer.dim { opacity: .4; }
.tq-answer.picked { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
.tq-answer.right { box-shadow: 0 0 0 4px var(--ok); opacity: 1; }
.tq-answer.right::after { content: '✓'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 22px; }
.tq-answer.wrong::after { content: '✗'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 22px; }
.tq-letter {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255, 255, 255, .2); font-size: 14px;
}
.tq-text { flex: 1; min-width: 0; padding-right: 22px; overflow-wrap: anywhere; }
.tq-answer small { flex-basis: 100%; padding-left: 40px; font-size: 12.5px; font-weight: 600; opacity: .9; }

.tq-result { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-size: 14.5px; color: var(--muted); }
.tq-result b { font-size: 18px; }
.tq-result .good { color: var(--ok); }
.tq-result .bad { color: var(--bad); }

.tq-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.tq-actions:empty { display: none; }
.tq-actions .btn { min-height: 44px; }

/* Host's picker before a game: how many questions and which categories. */
.tq-setup {
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); font-size: 14px;
}
.tq-setup[hidden] { display: none; }
.tq-setup h3 { margin: 0; font: 700 13px/1.2 var(--ui); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tq-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tq-chip {
  min-height: 36px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: 600 14px/1.2 var(--ui); cursor: pointer;
}
.tq-chip[aria-pressed="true"] { background: var(--brass); border-color: var(--brass); color: #1d160b; }
.tq-setup .muted { margin: 0; font-size: 13px; }

.tq-howto { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.tq-howto summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; }
.tq-howto ol { margin: 6px 0 4px; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); }
.tq-howto b { color: var(--text); }
.tq .sound-btn { padding: 0 10px; min-width: 40px; font-size: 1rem; }

.tq-players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tq-players li {
  display: flex; flex-direction: column; padding: 6px 12px; min-width: 88px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13.5px;
}
.tq-players li span { color: var(--muted); font-size: 12.5px; }
.tq-players li.answered { border-color: var(--ok-line); }
.tq-players li.me b { color: var(--brass-2); }
.tq-players li.away { opacity: .55; }
.tq-players li.winner { box-shadow: 0 0 0 3px var(--brass); }
.tq-remove {
  margin-left: 6px; min-width: 32px; min-height: 32px; padding: 0 6px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: inherit;
  font: inherit; font-size: 16px; line-height: 1; cursor: pointer; vertical-align: middle;
}
.tq-remove:hover { border-color: var(--brass); }

.tq-chat {
  display: flex; flex-direction: column; height: min(520px, 70dvh);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.tq-chat .log b { color: var(--brass-2); margin-right: 4px; }

@media (max-width: 760px) {
  .tq-main { grid-template-columns: minmax(0, 1fr); padding: 8px 10px 16px; gap: 10px; }
  .tq-card { padding: 14px 12px; }
  .tq-question { font-size: 19px; }
  .tq-chat { height: 200px; }
}
@media (max-width: 480px) {
  .tq-chip { padding: 6px 10px; font-size: 13.5px; }
  .tq-answers { grid-template-columns: 1fr; gap: 8px; }
  .tq-answer { min-height: 56px; font-size: 16px; }
}
