/* Dominó Online — feito primeiro para celular em pé */
:root {
  --feltro: #0f5c3c;
  --feltro-escuro: #0b3d2a;
  --feltro-claro: #17784f;
  --madeira: #5a3a22;
  --texto: #f4f1e8;
  --texto-suave: #b9d3c4;
  --ouro: #f4c542;
  --nos: #4fd18b;
  --eles: #ff7a6b;
  --dupla-a: #3fa9f5;
  --dupla-b: #f59e3f;
  --marfim: #fffdf5;
  --marfim2: #ece4cf;
  --pip: #1c1c1c;
  --sombra: 0 2px 6px rgba(0,0,0,.35);
  --raio: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color: var(--texto);
  background: radial-gradient(ellipse at 50% 35%, var(--feltro-claro), var(--feltro) 45%, var(--feltro-escuro) 100%);
  background-attachment: fixed;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
input, select, button { font: inherit; }
input, select { -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }

.tela { position: fixed; inset: 0; display: flex; flex-direction: column; padding-top: var(--safe-t); }

/* ---------- botões ---------- */
.bt {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px 16px;
  background: rgba(255,255,255,.12); color: var(--texto); font-weight: 600; font-size: 16px;
  cursor: pointer; transition: transform .08s, background .2s; margin: 8px 0;
}
.bt:active { transform: scale(.97); }
.bt:disabled { opacity: .45; cursor: default; }
.bt-primario { background: var(--ouro); color: #2a1f00; box-shadow: 0 3px 0 #b38c1d; }
.bt-grande { padding: 17px; font-size: 18px; }
.bt-link { background: none; color: var(--texto-suave); text-decoration: underline; font-weight: 500; padding: 10px; }
.bt-whats { background: #25d366; color: #05391b; box-shadow: 0 3px 0 #179a48; }
.ico {
  border: 0; background: rgba(0,0,0,.25); color: var(--texto); width: 42px; height: 42px; border-radius: 50%;
  font-size: 19px; display: grid; place-items: center; cursor: pointer; position: relative; flex: none;
}
.badge {
  position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--eles); color: #fff; font-size: 11px; font-style: normal; font-weight: 700; display: grid; place-items: center;
}

/* ---------- início ---------- */
#tela-inicio { overflow-y: auto; align-items: center; justify-content: center; padding: 20px; }
.inicio-box { width: 100%; max-width: 380px; }
.logo { text-align: center; margin-bottom: 18px; }
.logo h1 { margin: 10px 0 2px; font-size: 34px; letter-spacing: .5px; }
.logo h1 span { color: var(--ouro); }
.logo .sub { margin: 0; color: var(--texto-suave); }
.logo-pedras { position: relative; height: 92px; display: flex; justify-content: center; align-items: center; gap: 10px; }
.logo-pedras .pedra { position: relative; }
.logo-pedras .pedra:nth-child(1) { transform: rotate(-14deg); }
.logo-pedras .pedra:nth-child(2) { transform: translateY(-6px); }
.logo-pedras .pedra:nth-child(3) { transform: rotate(14deg); }
.campo { display: block; margin: 14px 0; }
.campo span { display: block; font-size: 14px; color: var(--texto-suave); margin-bottom: 6px; }
.campo input, .linha-entrar input, #chat-in {
  width: 100%; padding: 14px; border-radius: 12px; border: 2px solid transparent;
  background: rgba(0,0,0,.28); color: var(--texto); font-size: 17px; outline: none;
}
.campo input:focus, .linha-entrar input:focus, #chat-in:focus { border-color: var(--ouro); }
.ou { text-align: center; color: var(--texto-suave); margin: 6px 0; font-size: 14px; }
.linha-entrar { display: flex; gap: 8px; align-items: center; }
.linha-entrar input { text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }
.linha-entrar .bt { width: auto; padding: 14px 20px; margin: 0; }
.convite { background: rgba(0,0,0,.25); border-radius: var(--raio); padding: 14px; text-align: center; }
.convite b { color: var(--ouro); letter-spacing: 3px; font-size: 20px; }

/* ---------- topo ---------- */
.topo { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(0,0,0,.22); }
.topo-centro { flex: 1; text-align: center; font-size: 17px; }
.cod-sala { color: var(--ouro); letter-spacing: 3px; }
.placar { flex: 1; text-align: center; line-height: 1.15; }
.placar .pts { font-size: 20px; font-weight: 800; white-space: nowrap; }
.placar .nos { color: var(--nos); }
.placar .eles { color: var(--eles); }
.placar .x { opacity: .6; margin: 0 6px; font-weight: 400; }
.placar .meta { font-size: 11.5px; color: var(--texto-suave); }

/* ---------- lobby ---------- */
.lobby-corpo { flex: 1; overflow-y: auto; padding: 14px 16px calc(20px + var(--safe-b)); max-width: 520px; width: 100%; margin: 0 auto; }
.lobby-corpo h3 { margin: 22px 0 4px; }
.dica { color: var(--texto-suave); font-size: 14px; margin: 4px 0; }
.centro { text-align: center; }
.mesa-lobby {
  display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: auto auto auto; gap: 8px; margin-top: 12px;
  grid-template-areas: ". l2 ." "l3 mc l1" ". l0 .";
}
.mesa-lobby [data-lugar="0"] { grid-area: l0; }
.mesa-lobby [data-lugar="1"] { grid-area: l1; }
.mesa-lobby [data-lugar="2"] { grid-area: l2; }
.mesa-lobby [data-lugar="3"] { grid-area: l3; }
.mesa-centro {
  grid-area: mc; border-radius: 16px; background: var(--madeira);
  box-shadow: inset 0 0 0 6px #6d4a2e, var(--sombra); display: grid; place-items: center; font-size: 34px; min-height: 84px;
}
.lugar {
  border-radius: 14px; padding: 10px 6px; text-align: center; min-height: 84px; cursor: pointer;
  background: rgba(0,0,0,.22); border: 2px dashed rgba(255,255,255,.25); display: flex; flex-direction: column; justify-content: center; gap: 3px;
  font-size: 13px; position: relative;
}
.lugar.ocupado { border-style: solid; cursor: default; }
.lugar.dupla-a.ocupado { border-color: var(--dupla-a); }
.lugar.dupla-b.ocupado { border-color: var(--dupla-b); }
.lugar.eu { background: rgba(244,197,66,.18); }
.lugar .n { font-weight: 700; font-size: 15px; word-break: break-word; }
.lugar .num { font-size: 11px; color: var(--texto-suave); }
.lugar .off { color: var(--eles); font-size: 11px; }
.lugar .rem { border: 0; background: rgba(255,122,107,.2); color: var(--eles); border-radius: 8px; padding: 4px 6px; font-size: 11px; margin-top: 3px; cursor: pointer; }
.legenda-duplas { margin-top: 10px; font-size: 12.5px; color: var(--texto-suave); text-align: center; }
.tag { padding: 2px 7px; border-radius: 8px; font-weight: 700; font-size: 11.5px; }
.tag-a { background: var(--dupla-a); color: #062236; }
.tag-b { background: var(--dupla-b); color: #3a1f00; }
.config label { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 15px; }
.config select { background: rgba(0,0,0,.3); color: var(--texto); border: 0; border-radius: 10px; padding: 9px 10px; max-width: 58%; }

/* ---------- mesa do jogo ---------- */
.mesa-jogo {
  flex: 1; min-height: 0; display: grid; gap: 6px; padding: 6px 8px calc(8px + var(--safe-b));
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "esq topo dir" "tab tab tab" "status status status" "mao mao mao";
}
#pos-3 { grid-area: esq; }
#pos-2 { grid-area: topo; }
#pos-1 { grid-area: dir; }
#tabuleiro { grid-area: tab; }
#status-bar { grid-area: status; }
#minha-mao { grid-area: mao; }

.jogador {
  position: relative; border-radius: 12px; padding: 6px 6px 6px; background: rgba(0,0,0,.22);
  text-align: center; border: 2px solid transparent; transition: border-color .25s, box-shadow .25s; min-width: 0;
}
.jogador .av {
  width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 2px; display: grid; place-items: center; font-weight: 800; font-size: 16px;
  background: var(--eles); color: #3b0b05; position: relative;
}
.jogador.parceiro .av { background: var(--nos); color: #05341b; }
.jogador .av .on { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #3be07a; border: 2px solid var(--feltro-escuro); }
.jogador .av .on.off { background: #888; }
.jogador .nome { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jogador .papel { font-size: 10.5px; color: var(--texto-suave); }
.jogador .qtd { font-size: 12px; margin-top: 2px; display: flex; justify-content: center; align-items: center; gap: 4px; }
.costas { display: inline-flex; gap: 2px; }
.costas i { width: 6px; height: 11px; border-radius: 2px; background: linear-gradient(#2b2b2b, #111); border: 1px solid #555; }
.jogador.vez { border-color: var(--ouro); box-shadow: 0 0 0 3px rgba(244,197,66,.25), 0 0 18px rgba(244,197,66,.45); }
.jogador.vez .nome::before { content: "▶ "; color: var(--ouro); }
.balao {
  position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); white-space: nowrap; z-index: 5;
  background: #fff; color: #222; font-weight: 800; font-size: 12px; padding: 4px 9px; border-radius: 10px; box-shadow: var(--sombra);
  animation: balao 2.6s forwards;
}
@keyframes balao { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.8); } 10% { opacity: 1; transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

#tabuleiro {
  position: relative; border-radius: 18px; min-height: 0; overflow: hidden;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.06), rgba(0,0,0,.18));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.06), inset 0 4px 22px rgba(0,0,0,.35);
}
#tab-interno { position: absolute; inset: 0; }
#tab-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--texto-suave); font-size: 15px; pointer-events: none; }

#status-bar {
  text-align: center; font-size: 15px; padding: 7px 10px; border-radius: 12px; background: rgba(0,0,0,.25);
  min-height: 36px; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
}
#status-bar.minha { background: var(--ouro); color: #2a1f00; font-weight: 800; animation: pulsa 1.4s infinite; }
#status-bar .pontas { font-size: 12.5px; opacity: .85; font-weight: 600; white-space: nowrap; }
@keyframes pulsa { 50% { box-shadow: 0 0 0 4px rgba(244,197,66,.35); } }

#minha-mao { display: flex; justify-content: center; align-items: flex-end; gap: 6px; min-height: 64px; padding-top: 4px; }
.mao-item { position: relative; cursor: pointer; transition: transform .15s, opacity .2s, filter .2s; flex: none; }
.mao-item .pedra { position: relative; }
.mao-item.jogavel { transform: translateY(-8px); }
.mao-item.jogavel .pedra { box-shadow: 0 0 0 3px var(--ouro), 0 6px 14px rgba(0,0,0,.45); }
.mao-item.apagada { opacity: .42; filter: grayscale(.4); }
.mao-item.escolhida { transform: translateY(-16px) scale(1.05); }
.mao-item:active { transform: translateY(-4px) scale(.96); }

/* ---------- pedra de dominó ---------- */
.pedra {
  position: absolute; display: flex; border-radius: calc(var(--u) * .16);
  background: linear-gradient(150deg, var(--marfim), var(--marfim2));
  box-shadow: 0 1px 0 #cfc4a8, 0 2px 4px rgba(0,0,0,.45), inset 0 0 0 1px rgba(0,0,0,.08);
}
.pedra.h { flex-direction: row; }
.pedra.v { flex-direction: column; }
.meia { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 13%; position: relative; }
.pedra.h .meia + .meia { box-shadow: inset 1px 0 0 rgba(0,0,0,.28); }
.pedra.v .meia + .meia { box-shadow: inset 0 1px 0 rgba(0,0,0,.28); }
.pip { width: 74%; height: 74%; place-self: center; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #5a5a5a, var(--pip) 60%); }
.c0 { grid-area: 1 / 1; } .c1 { grid-area: 1 / 2; } .c2 { grid-area: 1 / 3; }
.c3 { grid-area: 2 / 1; } .c4 { grid-area: 2 / 2; } .c5 { grid-area: 2 / 3; }
.c6 { grid-area: 3 / 1; } .c7 { grid-area: 3 / 2; } .c8 { grid-area: 3 / 3; }
.pedra.ultima { box-shadow: 0 0 0 2px var(--ouro), 0 0 14px rgba(244,197,66,.8); }
.pedra.entra { animation: entra .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes entra { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pedra.marca-a { box-shadow: 0 0 0 3px var(--dupla-a), 0 0 16px var(--dupla-a); cursor: pointer; animation: pisca 1s infinite; }
.pedra.marca-b { box-shadow: 0 0 0 3px var(--dupla-b), 0 0 16px var(--dupla-b); cursor: pointer; animation: pisca 1s infinite; }
@keyframes pisca { 50% { filter: brightness(1.25); } }
.pedra.mini { position: relative; display: inline-flex; vertical-align: middle; margin: 2px; }

/* ---------- folhas (painéis de baixo) ---------- */
.folha { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; animation: fundo .2s; }
@keyframes fundo { from { background: rgba(0,0,0,0); } }
.folha-caixa {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: #12402d; border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(16px + var(--safe-b)); box-shadow: 0 -8px 30px rgba(0,0,0,.4); animation: sobe .25s ease-out;
}
@keyframes sobe { from { transform: translateY(40px); opacity: .4; } }
.folha-caixa > p { text-align: center; font-weight: 700; font-size: 17px; margin: 4px 0 10px; }
.ponta-opcoes { display: flex; gap: 10px; }
.bt-ponta { flex: 1; padding: 16px 8px; font-size: 17px; }
.bt-ponta.pa { background: var(--dupla-a); color: #062236; }
.bt-ponta.pb { background: var(--dupla-b); color: #3a1f00; }
.bt-ponta b { display: block; font-size: 30px; }

.chat-topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chat-caixa { display: flex; flex-direction: column; height: 72vh; }
#chat-lista { flex: 1; overflow-y: auto; padding: 4px 0; -webkit-user-select: text; user-select: text; }
.msg { margin: 6px 0; max-width: 85%; padding: 8px 11px; border-radius: 14px; background: rgba(255,255,255,.1); font-size: 15px; word-wrap: break-word; }
.msg b { display: block; font-size: 12px; color: var(--ouro); }
.msg.minha { margin-left: auto; background: rgba(244,197,66,.22); }
.chat-rapido { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.chat-rapido button { flex: none; border: 0; border-radius: 16px; padding: 8px 12px; background: rgba(255,255,255,.12); color: var(--texto); cursor: pointer; }
#chat-form { display: flex; gap: 8px; }
#chat-form .bt { width: auto; margin: 0; }

.fim-caixa { text-align: center; }
.fim-titulo { font-size: 24px; font-weight: 800; margin: 6px 0 2px; }
.fim-sub { color: var(--texto-suave); margin: 0 0 8px; }
.fim-pontos { display: inline-block; padding: 6px 14px; border-radius: 20px; font-weight: 800; font-size: 17px; margin: 6px 0; }
.fim-pontos.nos { background: var(--nos); color: #05341b; }
.fim-pontos.eles { background: var(--eles); color: #3b0b05; }
.fim-pontos.zero { background: rgba(255,255,255,.15); }
.fim-placar { font-size: 30px; font-weight: 800; margin: 8px 0; }
.fim-placar .nos { color: var(--nos); } .fim-placar .eles { color: var(--eles); }
.fim-maos { text-align: left; margin: 10px 0; }
.fim-mao { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid rgba(255,255,255,.08); }
.fim-mao .quem { width: 88px; flex: none; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fim-mao .quem small { display: block; font-weight: 400; color: var(--texto-suave); }
.fim-mao .pedras { flex: 1; display: flex; flex-wrap: wrap; align-items: center; min-height: 26px; }
.fim-mao .soma { flex: none; font-weight: 800; font-size: 15px; }
.trofeu { font-size: 54px; line-height: 1; animation: entra .6s; }
.buchuda { display: inline-block; background: var(--ouro); color: #2a1f00; font-weight: 800; padding: 4px 12px; border-radius: 12px; margin: 4px 0; }
.flutuante { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); width: auto; padding: 12px 22px; }

.regras ul { padding-left: 18px; line-height: 1.5; font-size: 15px; }
.regras table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.regras td { padding: 8px 4px; border-bottom: 1px solid rgba(255,255,255,.1); }
.regras td:last-child { text-align: right; white-space: nowrap; font-weight: 700; color: var(--ouro); }

#toasts { position: fixed; top: calc(60px + var(--safe-t)); left: 0; right: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 12px; }
.toast { background: rgba(10,25,18,.94); color: #fff; padding: 10px 16px; border-radius: 14px; box-shadow: var(--sombra); font-size: 14.5px; max-width: 420px; text-align: center; animation: toast 3.2s forwards; }
.toast.erro { background: #8b2318; }
.toast.destaque { background: var(--ouro); color: #2a1f00; font-weight: 700; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px); } 8% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }
.conexao { position: fixed; bottom: calc(6px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: #8b2318; padding: 6px 14px; border-radius: 12px; font-size: 13px; z-index: 90; }

/* ---------- telas grandes (computador / tablet deitado) ---------- */
@media (min-width: 900px) and (min-height: 560px) {
  .mesa-jogo {
    grid-template-columns: 170px minmax(0, 1fr) 170px;
    grid-template-areas: ". topo ." "esq tab dir" ". status ." ". mao .";
    gap: 10px; padding: 10px 16px 16px;
  }
  #pos-2 { justify-self: center; width: 200px; }
  #pos-1, #pos-3 { align-self: center; }
  .jogador { padding: 12px 8px; }
  .jogador .av { width: 48px; height: 48px; font-size: 21px; }
  .jogador .nome { font-size: 15px; }
  .costas i { width: 9px; height: 17px; }
  #status-bar { font-size: 17px; max-width: 640px; width: 100%; justify-self: center; }
  .folha { align-items: center; }
  .folha-caixa { border-radius: 22px; }
}
