/* Dominó — mesmo tema do Jogo da Velha (azul-noite, coral, turquesa, dourado) + mesa de feltro. Sem fontes externas, sem estilos inline. */
:root {
  --bg: #0b1226;
  --bg2: #101a33;
  --surface: #16224a;
  --surface2: #1c2b5c;
  --line: rgba(160, 180, 255, .16);
  --text: #eef2ff;
  --muted: #9fb0d9;
  --x: #ff6b57;
  --o: #2bb7a6;
  --felt: #0f5a3c;
  --felt2: #0a4430;
  --ivory: #f7f3e6;
  --gold: #ffd166;
  --danger: #ff8a7a;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); color: var(--text); line-height: 1.45;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2c66 0%, transparent 60%), var(--bg);
  display: flex; flex-direction: column;
}
a { color: var(--gold); }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- topo ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: rgba(11, 18, 38, .85);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: .2px; white-space: nowrap; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: url("../img/favicon.svg") center / cover no-repeat; flex: none; }
.topbar-right { display: inline-flex; align-items: center; gap: 14px; }
.toplink { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem; padding: 6px 10px; border-radius: 10px; }
.toplink:hover { color: var(--text); background: var(--surface); }

/* ---------- botões ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 11px 18px; border-radius: 12px; font-weight: 700; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; line-height: 1.2; min-height: 44px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--surface2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #ff826f, var(--x)); border-color: transparent; color: #2a0c07; box-shadow: 0 6px 18px rgba(255, 107, 87, .28); }
.btn-primary:hover { background: linear-gradient(180deg, #ff9382, #ff745f); }
.btn-ghost { background: transparent; }
.btn-teal { background: linear-gradient(180deg, #3cc9b8, var(--o)); border-color: transparent; color: #04211d; }
.btn-teal:hover { background: linear-gradient(180deg, #52d6c6, #33c0ae); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- páginas (início / ranking) ---------- */
.page { width: 100%; max-width: 760px; margin: 0 auto; padding: 28px 16px 40px; flex: 1; }
.hero { text-align: center; margin-bottom: 22px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.1; letter-spacing: -.5px; }
.hero h1 .x { color: var(--x); } .hero h1 .o { color: var(--gold); }
.hero p { margin: 0; color: var(--muted); font-size: 1.05rem; }

.notice { background: rgba(255, 138, 122, .12); border: 1px solid rgba(255, 138, 122, .45); color: #ffd3cc; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }

.card { background: linear-gradient(180deg, var(--surface), #131d40); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 4px; font-size: 1.15rem; }
.card .sub { margin: 0 0 14px; color: var(--muted); font-size: .95rem; }
.cards { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; margin-top: 16px; }
@media (max-width: 620px) { .cards { grid-template-columns: 1fr; } }

.nickbox { margin-bottom: 16px; }
.field { display: block; }
.field > span { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #0e1731; color: var(--text); min-height: 46px;
}
.input[readonly] { color: var(--gold); font-weight: 700; }
.input::placeholder { color: #6f80ad; }
.hint { margin: 8px 2px 0; font-size: .88rem; color: var(--muted); min-height: 1.3em; }
.hint.warn { color: var(--danger); }

.play-card { display: flex; align-items: center; gap: 18px; padding: 22px; }
.play-card .txt { flex: 1; min-width: 0; }
.play-card .btn { flex: none; min-width: 170px; font-size: 1.05rem; padding: 14px 22px; }
@media (max-width: 560px) {
  .play-card { flex-direction: column; text-align: center; }
  .play-card .btn { width: 100%; }
}

/* ---------- rodapé ---------- */
.site-footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 16px; border-top: 1px solid var(--line); }
.site-footer p { margin: 2px 0; }

/* ---------- ranking ---------- */
.tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.tabs .btn[aria-pressed="true"] { background: var(--surface2); border-color: var(--gold); color: var(--gold); }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.rank { width: 100%; border-collapse: collapse; }
.rank th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 14px; background: #131d40; }
.rank td { padding: 12px 14px; border-top: 1px solid var(--line); }
.rank .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank td.pos { width: 54px; color: var(--muted); font-weight: 700; }
.rank td.pts { font-weight: 800; color: var(--gold); }
.rank tr.top1 td.pos, .rank tr.top2 td.pos, .rank tr.top3 td.pos { color: #1b1300; }
.medal { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; font-size: .85rem; color: #1b1300; }
.medal.m1 { background: #ffd166; } .medal.m2 { background: #d5dbe8; } .medal.m3 { background: #e0a070; }
.who { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; word-break: break-word; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }
@media (max-width: 520px) {
  .rank th, .rank td { padding: 10px 8px; }
  .rank .hide-sm { display: none; }
}

/* ---------- avatar ---------- */
.avatar { position: relative; width: 52px; height: 52px; border-radius: 50%; overflow: hidden; flex: none; background: #22336f; display: grid; place-items: center; border: 2px solid var(--line); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar .initial { font-size: 1.25rem; color: var(--muted); text-transform: uppercase; }
.avatar.sm { width: 32px; height: 32px; } .avatar.sm .initial { font-size: .95rem; }

/* ---------- diálogos ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(5, 9, 22, .72); display: grid; place-items: center; padding: 16px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: min(100%, 380px); background: linear-gradient(180deg, var(--surface2), var(--surface)); border: 1px solid var(--line); border-radius: 20px; padding: 26px 22px 22px; text-align: center; box-shadow: var(--shadow); animation: pop .22s ease; }
@keyframes pop { from { transform: translateY(10px) scale(.96); opacity: 0; } }
.dialog-icon { font-size: 2.6rem; line-height: 1; margin-bottom: 8px; }
.dialog-title { margin: 0 0 6px; font-size: 1.5rem; }
.dialog-title.win { color: var(--gold); } .dialog-title.lose { color: var(--danger); }
.dialog-text { margin: 0 0 18px; color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.dialog-actions .btn { flex: 1; min-width: 130px; }

/* ---------- compartilhar ---------- */
.share { position: relative; display: inline-block; }
.share-btn { display: inline-flex; align-items: center; gap: 8px; flex: none; width: max-content; white-space: nowrap; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; min-height: 40px; }
.share-btn:hover { background: var(--surface2); }
.share-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 250px; margin: 0; padding: 8px; list-style: none; background: #14204a; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.share-title { display: none; font-weight: 800; padding: 6px 10px 10px; }
.share-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; background: transparent; color: var(--text); text-decoration: none; border-radius: 10px; cursor: pointer; text-align: left; font-weight: 600; }
.share-item:hover { background: var(--surface2); }
.share-ico { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; }
.share-backdrop { display: none; }
@media (max-width: 700px) {
  .share-menu { position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; border-radius: 20px 20px 0 0; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); z-index: 70; }
  .share-title { display: block; }
  .share-backdrop { display: block; position: fixed; inset: 0; background: rgba(5, 9, 22, .6); z-index: 65; }
  .share-backdrop[hidden] { display: none; }
  .share-btn-txt { display: none; }
  .share-btn { padding: 8px 10px; }
}
#f-join .btn { margin-top: 14px; }


.links { text-align: center; margin-top: 22px; }
.links a { color: var(--muted); font-weight: 600; }

/* ---------- peça de dominó (desenhada em CSS; --s = tamanho de uma metade) ---------- */
.dom {
  --s: 40px;
  display: inline-flex; flex: none; position: relative; border-radius: calc(var(--s) * .24);
  background: linear-gradient(160deg, #ffffff, #ebe4cf);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .28), inset 0 -3px 0 rgba(0, 0, 0, .08), 0 3px 7px rgba(0, 0, 0, .38);
  transition: transform .12s ease, box-shadow .12s ease, opacity .15s;
}
.dom.h { flex-direction: row; }
.dom.v { flex-direction: column; }
.dom .half { width: var(--s); height: var(--s); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: calc(var(--s) * .15); position: relative; }
.dom .half + .half::before { content: ""; position: absolute; background: rgba(0, 0, 0, .3); }
.dom.h .half + .half::before { left: 0; top: 16%; bottom: 16%; width: 2px; }
.dom.v .half + .half::before { top: 0; left: 16%; right: 16%; height: 2px; }
.dom .pip { place-self: center; width: 78%; height: 78%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4a4a4a, #0d0d0d 70%); }
.dom .pip.pip-1, .dom.red .pip { }
.dom.back { background: linear-gradient(160deg, #2b3a7a, #16224a); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25), 0 2px 4px rgba(0, 0, 0, .4); }
.dom.back .half { padding: 0; }
.dom.back .half::after { content: ""; position: absolute; inset: 22%; border-radius: 50%; background: rgba(255, 209, 102, .35); }
.dom.back .half + .half::after { display: none; }
.dom.back .half + .half::before { display: none; }
.dom.back { --s: 11px; }
.dom.back.v { width: 11px; height: 22px; }
.dom.mini { --s: 15px; }

/* ---------- partida ---------- */
.game { width: 100%; max-width: 760px; margin: 0 auto; padding: 12px 12px 20px; flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.messages { width: 100%; }
.alert { background: rgba(255, 138, 122, .14); border: 1px solid rgba(255, 138, 122, .5); color: #ffd3cc; padding: 10px 12px; border-radius: 12px; margin-bottom: 6px; font-size: .92rem; }

.opps { display: grid; gap: 8px; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); }
.pcard { display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-width: 0; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; transition: border-color .2s, box-shadow .2s, opacity .2s; }
.pcard.active { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(255, 209, 102, .14); }
.pcard.offline { opacity: .7; }
.pcard.out { opacity: .5; }
.pcard.winner { border-color: var(--gold); background: #2a2a1f; }
.pinfo { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.pname { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psub { font-size: .75rem; color: var(--muted); min-height: 1em; }
.backs { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.pcard .avatar { width: 40px; height: 40px; }
.opps.three .pcard, .opps.two .pcard { padding: 8px; gap: 8px; }
@media (max-width: 520px) {
  .opps.three { gap: 6px; }
  .opps.three .pcard { flex-direction: column; align-items: flex-start; gap: 4px; }
  .opps.three .avatar { width: 32px; height: 32px; }
}

.statusbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status-text { margin: 0; font-size: 1.1rem; font-weight: 700; min-height: 1.5em; flex: 1; }
.status-text.mine { color: var(--gold); }
.clock { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; background: conic-gradient(var(--gold) var(--pct, 0%), rgba(255, 255, 255, .1) 0); position: relative; }
.clock::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--bg2); }
.clock span { position: relative; }
.clock.urgent { color: var(--danger); animation: pulse .8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* mesa de feltro */
.table { position: relative; border-radius: 20px; padding: 14px 10px; min-height: 190px; display: flex; flex-direction: column; justify-content: center; gap: 8px;
  background: radial-gradient(120% 90% at 50% 20%, var(--felt) 0%, var(--felt2) 100%); box-shadow: inset 0 0 0 3px #5b3a1e, inset 0 0 0 5px rgba(255, 255, 255, .06), var(--shadow); }
.chain { --s: 30px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; }
.chain .dom { --s: inherit; }
.chain .dom.end { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .28), 0 0 0 3px rgba(255, 209, 102, .85), 0 0 14px rgba(255, 209, 102, .55); }
.chain .dom.fresh { animation: drop .28s ease-out; }
@keyframes drop { from { transform: translateY(-14px) scale(1.15); opacity: 0; } }
.table-hint { margin: 0; text-align: center; font-size: .82rem; color: rgba(255, 255, 255, .6); min-height: 1.2em; }
@media (max-width: 520px) { .chain { --s: 23px; gap: 3px; } .table { min-height: 170px; padding: 12px 6px; } }

.side-pick { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; background: var(--surface); border: 1px dashed rgba(255, 209, 102, .6); border-radius: 14px; padding: 10px; }
.side-pick span { font-weight: 700; color: var(--gold); }
.side-pick .btn { min-height: 40px; padding: 8px 14px; }

.handbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.handbar .pcard { flex: 1; }
.handbar .btn { flex: none; }
.hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 14px 8px 12px; border-radius: 16px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); min-height: 118px; align-items: flex-end; }
.hand .dom { --s: 40px; }
@media (max-width: 520px) { .hand { gap: 6px; padding: 12px 6px; } .hand .dom { --s: 36px; } }
@media (max-width: 380px) { .hand .dom { --s: 32px; } }
.hand .dom.playable { cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .28), 0 0 0 3px rgba(255, 209, 102, .9), 0 0 14px rgba(255, 209, 102, .45); }
.hand .dom.playable:hover { transform: translateY(-8px); }
.hand .dom.dim { opacity: .42; }
.hand .dom.sel { transform: translateY(-12px); }
.hand .dom.nope { animation: nope .3s; }
@keyframes nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.hand .dom { border: 0; padding: 0; background-clip: padding-box; }
.hand:empty::before { content: "As suas peças aparecem aqui quando a partida começa."; color: var(--muted); font-size: .9rem; align-self: center; }

.invite { width: 100%; text-align: center; background: var(--surface); border: 1px dashed rgba(255, 209, 102, .5); border-radius: 14px; padding: 12px; }
.invite p { margin: 0 0 8px; color: var(--muted); font-size: .92rem; }
.code-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.code-row code { font-size: 1.25rem; font-weight: 800; letter-spacing: .12em; color: var(--gold); background: #0e1731; padding: 8px 14px; border-radius: 10px; }
.actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- início ---------- */
.mini-dom { flex: none; display: flex; gap: 6px; transform: rotate(-8deg); }
.mini-dom .dom { --s: 24px; }
.players { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.pl-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pl-opt span { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: 12px; border: 2px solid var(--line); background: #0e1731; cursor: pointer; font-weight: 800; min-height: 60px; justify-content: center; font-size: 1.15rem; }
.pl-opt small { font-weight: 500; color: var(--muted); font-size: .75rem; }
.pl-opt input:checked + span { border-color: var(--gold); background: #17234d; }
.pl-opt input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
#f-join .btn { margin-top: 14px; }
.rules { margin-top: 18px; color: var(--muted); font-size: .92rem; }
.rules summary { cursor: pointer; font-weight: 700; color: var(--text); }
.rules ul { margin: 8px 0 0; padding-left: 20px; }
.rules li { margin: 4px 0; }

.alert.info { background: rgba(43, 183, 166, .13); border-color: rgba(43, 183, 166, .5); color: #c8f3ec; }
.copy-ghost { position: fixed; opacity: 0; pointer-events: none; }

.check { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; font-size: .92rem; color: var(--muted); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: #ffd166; flex: none; }
