/* ============ Fila de partida — bilhete de embarque ============
 * Aberta: bilhete creme no meio da tela (no celular, folha que sobe de baixo).
 * Minimizada: canhoto no canto (no celular, logo acima da barra de navegação).
 * Paleta da marca: papel creme, tinta azul-petróleo e azul. Sem vermelho/amarelo.
 */
#queue-root { position: relative; z-index: 55; }

/* ---------- aberta ---------- */
.qz-overlay { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 20px;
  background: rgba(3, 12, 18, .55); backdrop-filter: blur(3px); }
@keyframes qz-fade { from { opacity: 0; } }
.qz { position: relative; width: min(760px, 100%); color: var(--ink); background: var(--paper-tex); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(3, 12, 20, .6);
  /* furos do picote entre o corpo e o canhoto */
  -webkit-mask: radial-gradient(circle 13px at calc(100% - 190px) 0, transparent 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle 13px at calc(100% - 190px) 100%, transparent 98%, #000) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle 13px at calc(100% - 190px) 0, transparent 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle 13px at calc(100% - 190px) 100%, transparent 98%, #000) bottom / 100% 51% no-repeat; }
@keyframes qz-in { from { transform: translateY(24px) scale(.97); opacity: 0; } }
.qz-head { display: flex; justify-content: space-between; gap: 12px; padding: 9px 22px; background: var(--ink); color: var(--paper);
  border-radius: 16px 16px 0 0; font-size: 11px; font-weight: 900; letter-spacing: .22em; text-transform: uppercase; }
.qz-head span:last-child { color: #b9d2de; letter-spacing: .12em; white-space: nowrap; }
.qz-body { display: grid; grid-template-columns: 1fr 190px; }
.qz-main { padding: 18px 22px 12px; border-right: 2px dashed #b9b2a2; min-width: 0; }
.qz-route { display: flex; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.qz-route small { display: block; font-size: 10px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-muted); }
.qz-route b { font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1; color: var(--ink); }
.qz-route i { font-style: normal; font-size: 22px; color: var(--ink-muted); }

.qz-teams { display: flex; align-items: stretch; justify-content: center; gap: 10px; margin: 16px 0 8px; }
.qz-team { flex: 1 1 0; min-width: 0; padding: 8px 8px 6px; border-radius: 12px; background: rgba(21, 33, 43, .04); border: 1px solid #d6cdb9; }
.qz-team.mine { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.qz-tl { text-align: center; font-size: 10px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; color: var(--ink); }
.qz-seats { display: flex; justify-content: center; gap: 10px; margin-top: 8px; }
.qz-seat { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; flex: 1 1 0; max-width: 96px; }
.qz-seat small { font-size: 11px; font-weight: 700; color: #3b3a35; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.qz-seat.me small { color: var(--ink); font-weight: 900; }
.qz-seat.bot small, .qz-seat.search small { color: var(--ink-muted); }
.qz-seat .avatar.lg { width: 58px; height: 58px; }
.qz-seat.mate .avatar { box-shadow: 0 0 0 3px #3f89ae; }
@keyframes qz-pop { from { transform: scale(.6); } }
.qz-vs { align-self: center; font-family: var(--display); font-size: 30px; color: var(--ink-muted); }

/* lugar vazio: "?" girando procura de jogador */
.qz-q { position: relative; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(21, 33, 43, .05); border: 2px dashed #b9b2a2; }
.qz-q span { font-family: var(--display); font-size: 28px; color: var(--ink-muted); animation: qz-blink 1.6s ease-in-out infinite; }
.qz-q i { position: absolute; inset: -4px; border-radius: 50%; border: 2.5px solid transparent; border-top-color: #3f89ae; animation: qz-spin 1.2s linear infinite; }
.qz-seat.search:nth-child(2) .qz-q i { animation-delay: -.6s; }
@keyframes qz-spin { to { transform: rotate(360deg); } }
@keyframes qz-blink { 50% { opacity: .35; } }
.qz-pend { position: relative; opacity: .55; }
.qz-pend::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2.5px dashed #3f89ae; animation: qz-spin 3s linear infinite; }
.qz-seat.pend small b { color: var(--ink); }

/* trilho com o trenzinho procurando partida */
.qz-track { position: relative; height: 14px; margin: 12px 4px 4px; overflow: hidden; }
.qz-rail { position: absolute; left: 0; right: 0; top: 6px; height: 2px;
  background: repeating-linear-gradient(90deg, rgba(21, 33, 43, .35) 0 8px, transparent 8px 14px); }
.qz-train { position: absolute; top: 2px; left: -40px; width: 34px; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, transparent, #3f89ae 40%, var(--ink)); animation: qz-run 2.4s cubic-bezier(.5, 0, .5, 1) infinite; }
@keyframes qz-run { to { left: 100%; } }
.qz-fine { margin: 4px 0 0; text-align: center; font-size: 11.5px; color: var(--ink-muted); }

/* canhoto: tempo de espera */
.qz-stub { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 16px 10px; text-align: center; }
.qz-stub small { font-size: 11px; font-weight: 900; letter-spacing: .22em; text-transform: uppercase; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.qz-stub small::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #3f89ae; animation: qz-ping 1.4s ease-out infinite; }
@keyframes qz-ping { 0% { box-shadow: 0 0 0 0 rgba(63, 137, 174, .7); } 100% { box-shadow: 0 0 0 9px rgba(63, 137, 174, 0); } }
.qz-time { font-family: var(--display); font-weight: 400; font-size: 70px; line-height: .95; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.qz-stub > span { font-size: 11px; font-weight: 800; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .1em; }
/* jogador que a fila já achou pra mesa (ainda não é amigo da turma) */
.qz-seat.found .avatar { box-shadow: 0 0 0 3px #8db4c6; }
.qz-seat.found small { color: var(--ink); font-weight: 800; }
.qz-missing { display: block; margin-bottom: 3px; font-size: 12.5px; font-weight: 900; color: var(--ink); }
.qz-stub em { font-style: normal; margin-top: 10px; padding: 5px 10px; border-radius: 999px; font-size: 11.5px; color: #1f4a60;
  background: rgba(63, 137, 174, .12); border: 1.5px solid rgba(63, 137, 174, .35); }
.qz-stub em b { font-family: var(--display); font-weight: 400; font-size: 17px; color: #2f7495; }

/* "Jogar com bots": botão sólido (azul da marca), sem animação */
.qz-bots { display: flex; align-items: center; justify-content: center; width: 100%; max-width: 170px; min-height: 44px;
  margin-top: 12px; padding: 8px 12px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 900; letter-spacing: .02em; text-align: center; animation: none;
  color: var(--paper); background: linear-gradient(180deg, #4999bf, #337ca0); border: 1.5px solid #2f7495; box-shadow: 0 3px 0 #1e526d;
  transition: filter .15s, transform .1s, box-shadow .1s; }
.qz-bots:hover { filter: brightness(1.07); }
.qz-bots:active { transform: translateY(3px); box-shadow: 0 0 0 #1e526d; }
.qz-bots:disabled { opacity: .6; cursor: wait; transform: none; }
.qz-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 12px 22px 8px; border-top: 1px dashed #cfc7b5; }
.qz-actions .btn { min-height: 42px; }
.qz .btn.qz-min { background: transparent; color: var(--ink); border: 1.5px solid #b9b2a2 !important; }
.qz .btn.qz-min:hover { border-color: var(--ink) !important; background: rgba(21, 33, 43, .05); }
.qz .btn.qz-leave { background: var(--ink); color: var(--paper); border: 1.5px solid var(--ink) !important; }
.qz .btn.qz-leave:hover { background: #22323f; }
.qz-hint { margin: 0; padding: 0 22px 14px; text-align: center; font-size: 11px; color: var(--ink-muted); }

/* animação de entrada só quando a fila abre/minimiza, não a cada atualização (contador, convite…) */
#queue-root.qz-enter .qz-overlay { animation: qz-fade .2s ease-out; }
#queue-root.qz-enter .qz { animation: qz-in .38s cubic-bezier(.2, 1.3, .4, 1); }
#queue-root.qz-enter .qz-mini { animation: qz-mini-in .35s cubic-bezier(.2, 1.3, .4, 1); }

/* ---------- minimizada: canhoto flutuante ---------- */
.qz-mini { position: fixed; right: 20px; bottom: 20px; z-index: 36; display: flex; align-items: stretch; overflow: hidden;
  border-radius: 12px; color: var(--ink);
  background: var(--paper-tex); box-shadow: 0 12px 30px rgba(3, 12, 20, .55), inset 0 0 0 1.5px rgba(21, 33, 43, .12);
  transition: transform .2s, box-shadow .2s; }
.qz-mini::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; border-radius: 12px 0 0 12px; background: linear-gradient(180deg, #4999bf, #2f7495); }
.qz-mini:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(3, 12, 20, .6), inset 0 0 0 1.5px rgba(21, 33, 43, .18); }
/* parte grande: abre a fila */
.qzm-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 10px 2px 10px 20px; border: 0; background: transparent;
  font: inherit; color: inherit; text-align: left; cursor: pointer; }
.qzm-open:hover .qzm-max { color: var(--ink); }
/* depois do picote: sair da fila direto */
.qzm-leave { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 58px; flex-shrink: 0;
  border: 0; border-left: 2px dashed #b9b2a2; background: transparent; color: var(--ink); font: inherit; cursor: pointer; transition: background .15s; }
.qzm-leave b { font-size: 15px; line-height: 1; }
.qzm-leave span { font-size: 9.5px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.qzm-leave:hover { background: var(--ink); color: var(--paper); }
.qzm-leave:disabled { opacity: .5; cursor: wait; }
@keyframes qz-mini-in { from { transform: translateY(30px); opacity: 0; } }
.qzm-ic { position: relative; width: 28px; height: 28px; border-radius: 50%; border: 2px dashed #b9b2a2; flex-shrink: 0; }
.qzm-ic i { position: absolute; inset: -3px; border-radius: 50%; border: 2.5px solid transparent; border-top-color: #3f89ae; animation: qz-spin 1.2s linear infinite; }
.qzm-tx { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; flex: 1; }
.qzm-tx small { font-size: 9.5px; font-weight: 900; letter-spacing: .2em; text-transform: uppercase; color: #2f7495; }
.qzm-tx b { font-size: 13.5px; font-weight: 900; color: var(--ink); white-space: nowrap; }
/* tempo embaixo da info, numa moldurinha de bilhete */
.qzm-time { align-self: stretch; margin-top: 7px; padding: 5px 12px 3px; border: 1.5px solid #2f7495; border-radius: 5px;
  box-shadow: inset 0 0 0 2px #ebe3cf, inset 0 0 0 3px rgba(47, 116, 149, .35);
  font-family: var(--display); font-size: 36px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; text-align: center; }
.qzm-max { width: 16px; margin-left: -8px; text-align: center; font-size: 13px; color: var(--ink-muted); transition: color .15s; }

/* ---------- partida encontrada ---------- */
.qz-found { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; pointer-events: none; }
.qzf-stamp { display: flex; flex-direction: column; align-items: center; padding: 14px 30px 12px; border-radius: 14px; color: var(--ink);
  background: var(--paper-tex); border: 3px double var(--ink); box-shadow: 0 20px 50px rgba(3, 12, 20, .6);
  transform: rotate(-4deg); animation: qzf-stamp 1.7s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.qzf-stamp small { font-size: 10px; font-weight: 900; letter-spacing: .3em; text-transform: uppercase; color: #2f7495; }
.qzf-stamp b { font-family: var(--display); font-weight: 400; font-size: 46px; line-height: 1; }
.qzf-stamp span { font-size: 12px; font-weight: 800; color: var(--ink-muted); }
@keyframes qzf-stamp { 0% { transform: rotate(-4deg) scale(1.8); opacity: 0; } 18% { transform: rotate(-4deg) scale(1); opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: rotate(-4deg) scale(.96); } }

/* ---------- lobby: bilhete na fila / botão de treino na fila ---------- */
.tk-btn.in-queue { background: var(--ink) !important; color: var(--paper) !important; cursor: pointer; }
.tk-btn.in-queue em { font-style: normal; font-variant-numeric: tabular-nums; }
.tkq-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #8db4c6; vertical-align: 1px; animation: qz-ping 1.4s ease-out infinite; }
.tk-wrap.queued .ticket { box-shadow: 0 0 0 3px #3f89ae, 0 0 22px rgba(63, 137, 174, .45); }
#btn-practice.in-queue { background: var(--ink) !important; color: var(--paper) !important; border-color: var(--ink) !important; }
#btn-practice.in-queue em { font-style: normal; font-variant-numeric: tabular-nums; }
#btn-practice:disabled, #btn-create:disabled, .tables-list [data-join]:disabled { opacity: .5; cursor: not-allowed; }
.tk-mini.queued { box-shadow: 0 0 0 2.5px #3f89ae, 0 6px 16px rgba(3, 12, 20, .4) !important; }
.tkm-q { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 4px; font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: #2f7495; }
.tkm-q i { width: 6px; height: 6px; border-radius: 50%; background: #3f89ae; animation: qz-ping 1.4s ease-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .qz, .qz-mini, .qz-overlay, .qzf-stamp { animation: none; }
  .qz-train { animation-duration: 6s; }
}

/* ============ celular (estilo app) ============ */
@media (max-width: 760px) {
  /* aberta: folha que sobe de baixo, com alça, rolável se a tela for baixa */
  .qz-overlay { place-items: end center; padding: 0; }
  .qz { width: 100%; max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; border-radius: 18px 18px 0 0;
    -webkit-mask: none; mask: none; padding-bottom: env(safe-area-inset-bottom); }
  #queue-root.qz-enter .qz { animation: qz-sheet .32s cubic-bezier(.2, 1, .3, 1); }
  @keyframes qz-sheet { from { transform: translateY(100%); } }
  .qz::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 3px; background: rgba(244, 240, 230, .45);
    position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 2; }
  .qz-head { border-radius: 18px 18px 0 0; padding: 16px 14px 8px; font-size: 10px; letter-spacing: .14em; }
  .qz-head span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .qz-body { grid-template-columns: 1fr; }
  .qz-main { border-right: 0; border-bottom: 2px dashed #b9b2a2; padding: 14px 12px 10px; }
  .qz-route { gap: 10px; }
  .qz-route b { font-size: 24px; }
  .qz-route small { font-size: 8.5px; letter-spacing: .1em; }
  .qz-teams { gap: 4px; margin: 12px 0 6px; }
  .qz-team { padding: 7px 4px 4px; }
  .qz-tl { font-size: 9px; letter-spacing: .08em; }
  .qz-seats { gap: 4px; }
  .qz-seat .avatar.lg, .qz-q { width: 44px; height: 44px; }
  .qz-q span { font-size: 22px; }
  .qz-seat small { font-size: 10px; }
  .qz-vs { font-size: 22px; }
  /* canhoto vira uma faixa horizontal */
  .qz-stub { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 10px; padding: 10px 12px; }
  .qz-time { font-size: 44px; }
  .qz-stub em { margin-top: 0; flex-basis: auto; }
  .qz-bots { margin-top: 6px; flex-basis: 100%; max-width: none; min-height: 46px; }
  .qz-actions { display: grid; grid-template-columns: 1fr 1fr; padding: 10px 12px 6px; }
  .qz-actions .btn { width: 100%; min-height: 46px; justify-content: center; }
  .qz-actions .btn.primary { grid-column: 1 / -1; }
  .qz-hint { padding: 2px 14px 12px; font-size: 10.5px; }

  /* minimizada: canhoto ocupando a largura, logo acima da barra de baixo */
  .qz-mini { left: 10px; right: 10px; bottom: calc(74px + env(safe-area-inset-bottom)); min-width: 0; }
  .qzm-open { gap: 10px; padding: 9px 2px 9px 16px; }
  .qzm-leave { width: 56px; } /* área de toque confortável */
  /* celular: tempo continua à direita, grande e sem moldura */
  .qzm-tx { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 6px; }
  .qzm-tx small, .qzm-tx b { grid-column: 1; }
  .qzm-time { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin: 0; padding: 0 4px; border: 0; box-shadow: none; font-size: 26px; min-width: 62px; }
  /* espaço pro canhoto não cobrir o fim da página */
  body:has(.qz-mini) #page { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  body:has(.qz-mini) .toasts { bottom: calc(140px + env(safe-area-inset-bottom)); }
  .qzf-stamp b { font-size: 36px; }
}
@media (max-width: 380px) {
  .qz-seat .avatar.lg, .qz-q { width: 38px; height: 38px; }
  .qz-route b { font-size: 20px; }
}
/* celular deitado / tela baixa */
@media (max-height: 520px) and (max-width: 960px) {
  .qz-overlay { place-items: center; padding: 8px; }
  .qz { max-height: calc(100dvh - 16px); overflow-y: auto; }
  .qz-time { font-size: 44px; }
}
