:root {
  --felt-1: #13704f;
  --felt-2: #0b4a34;
  --felt-3: #062b1f;
  --gold: #f2c14e;
  --gold-2: #d99a1e;
  --ink: #f4f1e8;
  --muted: rgba(244, 241, 232, .62);
  --panel: rgba(4, 26, 18, .55);
  --panel-2: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .12);
  --red: #d42a3a;
  --black: #1b1f2a;
  --card-bg: #fffdf7;
  --ok: #4ade80;
  --bad: #f87171;
  --clean: #f2c14e;
  --dirty: #8fb8ff;
  --cw: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--felt-3);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

#app {
  position: fixed; inset: 0;
  margin: 0 auto; max-width: 520px;
  background:
    radial-gradient(120% 70% at 50% 45%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  overflow: hidden;
  box-shadow: 0 0 80px rgba(0,0,0,.6);
}
#app::before { /* textura do feltro */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 3px 3px;
}

.screen { position: absolute; inset: 0; display: none; flex-direction: column; padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
.screen.active { display: flex; animation: fadeIn .35s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }

/* ===== Botões ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px; font-weight: 700; letter-spacing: .2px;
  background: var(--panel-2); border: 1px solid var(--line);
  transition: transform .12s var(--ease), filter .2s, opacity .2s, background .2s;
  min-height: 46px;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .38; pointer-events: none; filter: grayscale(.6); }
.btn.primary { background: linear-gradient(180deg, #2fc77c, #179457); border-color: rgba(255,255,255,.25); box-shadow: 0 6px 18px rgba(23,148,87,.4), inset 0 1px 0 rgba(255,255,255,.3); }
.btn.gold { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #3b2500; border-color: rgba(255,255,255,.35); box-shadow: 0 6px 18px rgba(217,154,30,.35), inset 0 1px 0 rgba(255,255,255,.4); }
.btn.danger { background: linear-gradient(180deg, #ef5160, #b81f2e); border-color: rgba(255,255,255,.2); }
.btn.ghost { background: transparent; }
.btn.big { padding: 15px 22px; font-size: 17px; border-radius: 16px; }
.btn.full { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--panel-2); border: 1px solid var(--line); flex: none; }
.icon-btn.small { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
.icon-btn:active { transform: scale(.92); }
.link-btn { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 10px; margin-top: 8px; }

/* ===== Home ===== */
.home-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 22px; gap: 18px; overflow-y: auto; }
.logo { text-align: center; margin-bottom: 6px; }
.logo h1 { margin: 10px 0 0; font-size: 46px; letter-spacing: 1px; font-weight: 900; font-family: Georgia, "Times New Roman", serif; color: var(--gold); text-shadow: 0 3px 0 #7a4e05, 0 8px 24px rgba(0,0,0,.5); }
.logo .tag { margin: 4px 0 0; color: var(--muted); letter-spacing: 3px; text-transform: uppercase; font-size: 12px; }
.logo-cards { position: relative; height: 104px; width: 160px; margin: 0 auto; }
.lc { position: absolute; left: 50%; top: 8px; width: 62px; height: 88px; border-radius: 9px; background: var(--card-bg); color: var(--black); font-weight: 800; font-size: 22px; padding: 6px 8px; box-shadow: 0 8px 20px rgba(0,0,0,.4); display: flex; flex-direction: column; line-height: 1; font-family: Georgia, serif; }
.lc span { font-size: 20px; }
.lc.red { color: var(--red); }
.lc1 { transform: translateX(-50%) rotate(-16deg) translateX(-34px); animation: floatA 4s ease-in-out infinite; }
.lc2 { transform: translateX(-50%) rotate(0deg) translateY(-6px); z-index: 2; animation: floatB 4s ease-in-out infinite; }
.lc3 { transform: translateX(-50%) rotate(16deg) translateX(34px); animation: floatC 4s ease-in-out infinite; }
@keyframes floatA { 50% { transform: translateX(-50%) rotate(-19deg) translateX(-38px) translateY(-3px); } }
@keyframes floatB { 50% { transform: translateX(-50%) translateY(-11px); } }
@keyframes floatC { 50% { transform: translateX(-50%) rotate(19deg) translateX(38px) translateY(-3px); } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--muted); padding-left: 4px; }
.field input, .join-row input, .custom-target input {
  background: rgba(0,0,0,.28); border: 1px solid var(--line); color: var(--ink); border-radius: 14px; padding: 14px 16px; font-size: 17px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .join-row input:focus, .custom-target input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242,193,78,.2); }
.home-actions { display: flex; flex-direction: column; gap: 14px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 800; font-size: 20px; }

/* ===== Setup ===== */
.sheet-page { flex: 1; overflow-y: auto; padding: 14px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.page-head h2 { margin: 0; font-size: 22px; }
.setting { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: block; }
.setting-title { font-weight: 700; margin-bottom: 10px; }
.setting-sub { font-size: 13px; color: var(--muted); margin-top: -6px; }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip { padding: 11px 4px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 700; transition: all .2s var(--ease); }
.chip.active { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #3b2500; border-color: transparent; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(217,154,30,.35); }
.custom-target { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.custom-target input { flex: 1; min-width: 0; }
.seg { display: flex; background: rgba(0,0,0,.3); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 10px 6px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); transition: all .2s var(--ease); }
.seg button.active { background: var(--ink); color: #0b3d2e; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.toggle-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle-row > div { flex: 1; }
.toggle-row .setting-title { margin-bottom: 8px; }
.toggle-row input { display: none; }
.switch { width: 52px; height: 30px; border-radius: 30px; background: rgba(0,0,0,.4); position: relative; transition: background .2s; flex: none; border: 1px solid var(--line); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: transform .25s var(--ease); }
.toggle-row input:checked + .switch { background: #23b26a; }
.toggle-row input:checked + .switch::after { transform: translateX(22px); }

/* ===== Lobby ===== */
.lobby-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; gap: 10px; text-align: center; overflow-y: auto; }
.lobby-wrap p { margin: 0; }
.room-code { font-size: 54px; font-weight: 900; letter-spacing: 12px; padding-left: 12px; color: var(--gold); text-shadow: 0 4px 18px rgba(0,0,0,.4); font-family: ui-monospace, Menlo, monospace; }
.qr { width: 190px; height: 190px; background: #fff; border-radius: 18px; padding: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.qr svg { width: 100%; height: 100%; display: block; }
.join-url { font-size: 13px; color: var(--muted); word-break: break-all; -webkit-user-select: text; user-select: text; }
.waiting { margin-top: 10px; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.lobby-settings { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.pill { font-size: 12px; padding: 5px 10px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }

/* ===== Mesa ===== */
#screen-game { gap: 0; }
.pbar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; flex: none; }
.pbar.opp { background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.12)); border-bottom: 1px solid var(--line); }
.pbar.me { padding: 4px 10px; min-height: 40px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 17px; background: linear-gradient(135deg, #6d5bd0, #3c2f8f); border: 2px solid rgba(255,255,255,.3); flex: none; transition: box-shadow .3s; }
.pchip.turn .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 18px var(--gold); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 4px var(--gold); } }
.pinfo { flex: 1; min-width: 0; }
.pname { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); flex: none; }
.conn.off { background: #888; box-shadow: none; }
.pstats { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.stat { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: rgba(0,0,0,.3); color: var(--muted); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.stat.on { color: var(--ink); }
.stat.r3 { color: #ffb3bb; }
.stat.go { background: rgba(74,222,128,.18); color: var(--ok); }
.mini-back { width: 9px; height: 12px; border-radius: 2px; background: linear-gradient(135deg, #b8323f, #7a1b26); border: 1px solid rgba(255,255,255,.5); display: inline-block; }
.score-box { text-align: right; flex: none; }
.score { font-size: 20px; font-weight: 900; color: var(--gold); line-height: 1; font-variant-numeric: tabular-nums; }
.score-sub { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.hint { flex: 2; font-size: 12.5px; text-align: center; color: var(--muted); line-height: 1.25; min-height: 16px; transition: color .2s; }
.hint.ok { color: var(--ok); } .hint.bad { color: var(--bad); }

/* áreas de jogos */
.meld-area { position: relative; flex: 1 1 0; min-height: 0; padding: 6px 8px; overflow-y: auto; overflow-x: hidden; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 10px 6px; }
.meld-area.opp { flex-grow: 1; }
.meld-area.mine { flex-grow: 1.35; border-top: 1px dashed rgba(255,255,255,.08); }
.meld-area:empty::after { content: attr(data-empty); position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.22); font-size: 13px; letter-spacing: .5px; pointer-events: none; }
.meld {
  position: relative; border-radius: 8px; padding: 2px; transition: transform .2s var(--ease), box-shadow .25s, background .25s; flex: none;
}
.meld .card { position: absolute; left: 2px; }
.meld.canastra.clean { background: rgba(242,193,78,.18); box-shadow: 0 0 0 2px var(--clean), 0 0 14px rgba(242,193,78,.45); }
.meld.canastra.dirty { background: rgba(143,184,255,.14); box-shadow: 0 0 0 2px var(--dirty); }
.meld .badge { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 6px; z-index: 50; letter-spacing: .5px; white-space: nowrap; }
.meld.clean .badge { background: var(--clean); color: #3b2500; }
.meld.dirty .badge { background: var(--dirty); color: #0d2350; }
.meld.target { box-shadow: 0 0 0 2px var(--ok), 0 0 16px rgba(74,222,128,.6); background: rgba(74,222,128,.12); animation: targetPulse 1.2s infinite; }
@keyframes targetPulse { 50% { box-shadow: 0 0 0 2px var(--ok), 0 0 4px rgba(74,222,128,.3); } }
.meld:active { transform: scale(.97); }
.meld.flash { animation: meldFlash .8s var(--ease); }
@keyframes meldFlash { 0% { transform: scale(1.12); filter: brightness(1.4); } 100% { transform: scale(1); } }

/* centro */
.center-strip { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 6px 18px; gap: 10px; background: linear-gradient(90deg, transparent, rgba(0,0,0,.2), transparent); border-top: 1px solid rgba(255,255,255,.05); border-bottom: 1px solid rgba(255,255,255,.05); }
.pile { position: relative; width: 64px; height: 88px; flex: none; }
.pile .card { --cw: 56px; }
.stack { position: absolute; inset: 0; }
.stack .card { position: absolute; left: 2px; top: 6px; }
.stack .card:nth-child(2) { top: 3px; left: 4px; }
.stack .card:nth-child(3) { top: 0; left: 6px; }
.pile-count { position: absolute; top: -6px; right: -8px; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 11px; background: #0a2018; border: 1px solid var(--line); font-size: 12px; font-weight: 800; display: grid; place-items: center; z-index: 5; font-variant-numeric: tabular-nums; }
.pile-label { position: absolute; bottom: -16px; width: 100%; text-align: center; font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.pile.active .stack .card:nth-child(3), .pile.active .lixo-slot { box-shadow: 0 0 0 3px var(--gold), 0 0 20px var(--gold); animation: pileGlow 1.4s infinite; }
@keyframes pileGlow { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 6px var(--gold); } }
.pile.disabled { opacity: .5; }
.pile.empty .stack { display: none; }
.lixo-slot { position: absolute; left: 4px; top: 0; width: 56px; height: 78px; border-radius: 8px; border: 2px dashed rgba(255,255,255,.18); }
.lixo-slot .card { position: absolute; left: -2px; top: -2px; }
.lixo-slot.has { border-color: transparent; }
.lixo-slot.has::before { content: ""; position: absolute; left: 1px; top: 2px; width: 56px; height: 78px; border-radius: 8px; background: #e9e4d6; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.lixo .lock { position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 26px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); animation: lockIn .4s var(--ease); }
@keyframes lockIn { from { transform: translate(-50%, -50%) scale(2); opacity: 0; } }
.turn-info { flex: 1; text-align: center; min-width: 0; }
.turn-text { font-weight: 800; font-size: 15px; line-height: 1.25; }
.turn-text.mine { color: var(--gold); }
.target-text { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* mão */
.hand { position: relative; flex: none; margin: 0 6px; transition: height .25s var(--ease); }
.hand .card { position: absolute; transition: left .3s var(--ease), top .3s var(--ease), translate .18s var(--ease), box-shadow .2s; will-change: left, translate; }
.hand .card.sel { translate: 0 -16px; box-shadow: 0 0 0 2.5px var(--gold), 0 10px 20px rgba(0,0,0,.45); }
.hand .card.fresh::after { content: ""; position: absolute; inset: -3px; border-radius: 10px; box-shadow: 0 0 0 2px rgba(143,184,255,.9), 0 0 14px rgba(143,184,255,.8); pointer-events: none; animation: freshFade 2.5s forwards; }
@keyframes freshFade { 70% { opacity: 1; } 100% { opacity: 0; } }
.hand .card.enter { animation: dealIn .45s var(--ease) both; }
@keyframes dealIn { from { transform: translateY(-160px) scale(.5) rotate(-10deg); opacity: 0; } }
.hand.not-turn .card { filter: brightness(.92); }

/* ações */
.actions { flex: none; display: flex; gap: 8px; padding: 8px 10px calc(10px + var(--safe-b) * 0); align-items: center; min-height: 62px; }
.actions .btn { flex: 1; padding: 10px 8px; font-size: 15px; min-height: 44px; }
.actions .btn.sq { flex: none; width: 46px; padding: 0; font-size: 18px; }
.actions .waiting-msg { flex: 1; text-align: center; color: var(--muted); font-size: 14px; }

/* ===== Cartas ===== */
.card {
  --ch: calc(var(--cw) * 1.4);
  width: var(--cw); height: var(--ch);
  border-radius: calc(var(--cw) * .13);
  background: linear-gradient(160deg, #ffffff 0%, var(--card-bg) 60%, #f1ead8 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.2), inset 0 0 0 1px rgba(0,0,0,.08);
  color: var(--black);
  font-family: Georgia, "Times New Roman", serif;
  overflow: hidden;
}
.card.red { color: var(--red); }
.card .ct { position: absolute; left: calc(var(--cw) * .07); top: calc(var(--cw) * .05); display: flex; flex-direction: column; align-items: center; line-height: .95; font-weight: 800; }
.card .ct .r { font-size: calc(var(--cw) * .36); letter-spacing: -1px; }
.card .ct .s { font-size: calc(var(--cw) * .3); margin-top: 1px; }
.card .cc { position: absolute; right: calc(var(--cw) * .08); bottom: calc(var(--cw) * .06); font-size: calc(var(--cw) * .62); line-height: 1; opacity: .95; }
.card.face .cc { font-size: calc(var(--cw) * .52); font-weight: 900; }
.card.face { background: linear-gradient(160deg, #fffaf0 0%, #fbf0d6 100%); }
.card.wild { background: linear-gradient(160deg, #fffbe9 0%, #ffeeb3 100%); }
.card.wild::before { content: "★"; position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); font-size: calc(var(--cw) * .5); color: rgba(217,154,30,.35); }
.card.b3::before { content: "🔒"; position: absolute; left: 52%; top: 46%; transform: translate(-50%, -50%); font-size: calc(var(--cw) * .3); opacity: .55; }
/* cartas em jogos: canto em linha para ficar legível empilhado */
.card.m .ct { flex-direction: row; gap: 1px; align-items: baseline; top: calc(var(--cw) * .04); }
.card.m .ct .r { font-size: calc(var(--cw) * .34); }
.card.m .ct .s { font-size: calc(var(--cw) * .3); margin: 0; }
.card.m .cc { font-size: calc(var(--cw) * .7); }
.card.m.wild::before, .card.m.b3::before { top: 60%; }
.card.pop { animation: pop .5s var(--ease); }
@keyframes pop { from { transform: translateY(-30px) scale(1.15); filter: brightness(1.2); } }

.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.09) 0 4px, transparent 4px 8px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.07) 0 4px, transparent 4px 8px),
    linear-gradient(135deg, #c13646, #7a1b26);
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px rgba(0,0,0,.15), 0 2px 6px rgba(0,0,0,.4);
}
.card.drop-opp { animation: dropOpp .45s var(--ease); }
.card.drop-me { animation: dropMe .45s var(--ease); }
@keyframes dropOpp { from { transform: translateY(-140px) rotate(-14deg) scale(.8); opacity: 0; } }
@keyframes dropMe { from { transform: translateY(220px) rotate(12deg) scale(1.1); opacity: 0; } }

/* ===== Modais ===== */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal.open { display: flex; animation: fadeOnly .25s; }
@keyframes fadeOnly { from { opacity: 0; } }
.modal-card { width: 100%; max-width: 440px; max-height: 92%; overflow-y: auto; background: linear-gradient(180deg, #154e3a, #0a3326); border: 1px solid rgba(255,255,255,.15); border-radius: 22px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: modalIn .35s var(--ease); }
.modal-card.tall { height: 88%; display: flex; flex-direction: column; padding: 0; }
@keyframes modalIn { from { transform: translateY(30px) scale(.96); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 19px; }
#modal-menu { align-items: flex-end; padding: 0; }
.modal-card.sheet { border-radius: 22px 22px 0 0; max-width: 520px; padding: 8px 12px calc(16px + var(--safe-b)); animation: sheetIn .3s var(--ease); }
@keyframes sheetIn { from { transform: translateY(100%); } }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 4px auto 10px; }
.menu-item { display: block; width: 100%; text-align: left; padding: 15px 14px; border-radius: 12px; font-size: 16px; }
.menu-item:active { background: var(--panel-2); }
.menu-item b { color: var(--gold); font-weight: 700; }
.menu-item.danger { color: #ff8a95; }
.menu-item.muted { color: var(--muted); text-align: center; }

.rules-body { overflow-y: auto; padding: 6px 18px 24px; font-size: 14.5px; line-height: 1.5; -webkit-user-select: text; user-select: text; }
.rules-body h4 { color: var(--gold); margin: 18px 0 6px; font-size: 15px; }
.rules-body ul { padding-left: 20px; margin: 6px 0; }
.rules-body li { margin: 3px 0; }
.rules-body table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.rules-body td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
.rules-body td:last-child { text-align: right; font-weight: 700; color: var(--gold); }

/* resultado */
.result-head { text-align: center; margin-bottom: 12px; }
.result-head .big-emoji { font-size: 46px; animation: bounceIn .6s var(--ease); }
@keyframes bounceIn { 0% { transform: scale(.2); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
.result-head h3 { margin: 4px 0 2px; font-size: 22px; }
.result-head p { margin: 0; color: var(--muted); font-size: 14px; }
.score-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.score-table th { font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 4px; text-align: right; }
.score-table th:first-child { text-align: left; }
.score-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.score-table td:first-child { text-align: left; color: var(--muted); }
.score-table .neg { color: var(--bad); } .score-table .pos { color: var(--ok); }
.score-table tr.total td { font-weight: 900; font-size: 16px; color: var(--ink); border-bottom: 0; }
.score-table tr.match td { font-weight: 900; font-size: 18px; color: var(--gold); border-bottom: 0; }
.progress { height: 8px; border-radius: 4px; background: rgba(0,0,0,.35); overflow: hidden; margin-top: 4px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); border-radius: 4px; transition: width 1s var(--ease); }
.result-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.result-actions .row { display: flex; gap: 8px; }
.result-actions .row .btn { flex: 1; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.actions .btn { white-space: nowrap; }
.ready-note { text-align: center; color: var(--muted); font-size: 13px; }
.show-result { position: fixed; z-index: 90; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); padding: 12px 22px; border-radius: 30px; font-weight: 800; background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #3b2500; box-shadow: 0 8px 24px rgba(0,0,0,.5); }

/* toasts */
.toasts { position: fixed; z-index: 150; left: 0; right: 0; top: var(--toast-top, 40%); transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 16px; }
.toast { max-width: 440px; background: rgba(8, 24, 18, .94); backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,.14); padding: 9px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.45); animation: toastIn .3s var(--ease); text-align: center; }
.toast.err { border-color: rgba(248,113,113,.6); background: rgba(70, 12, 18, .95); }
.toast.good { border-color: rgba(242,193,78,.6); }
.toast.out { animation: toastOut .3s forwards; }
@keyframes toastIn { from { transform: translateY(-14px) scale(.95); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.conn-banner { position: fixed; z-index: 200; top: 0; left: 0; right: 0; padding: calc(6px + var(--safe-t)) 10px 6px; background: #b8862a; color: #241500; text-align: center; font-weight: 700; font-size: 13px; }

.react-pop { position: fixed; z-index: 120; top: calc(56px + var(--safe-t)); right: 12px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; max-width: calc(100vw - 24px); padding: 6px; border-radius: 18px; background: rgba(8,24,18,.95); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: toastIn .2s var(--ease); }
.react-pop button { font-size: 25px; width: 46px; height: 46px; border-radius: 12px; }
.react-pop button:active { background: var(--panel-2); transform: scale(.9); }

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 160; overflow: hidden; }
.float-emoji { position: absolute; font-size: 54px; animation: floatUp 2s var(--ease) forwards; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
@keyframes floatUp { 0% { transform: translateY(0) scale(.3); opacity: 0; } 15% { transform: translateY(-20px) scale(1.2); opacity: 1; } 100% { transform: translateY(-160px) scale(1); opacity: 0; } }
.confetti { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: confetti linear forwards; }
@keyframes confetti { to { transform: translateY(110vh) rotate(720deg); } }

.rotate-overlay { display: none; }
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .rotate-overlay { display: flex; position: fixed; inset: 0; z-index: 500; background: var(--felt-3); flex-direction: column; align-items: center; justify-content: center; gap: 18px; font-weight: 700; }
  .rot-phone { width: 46px; height: 80px; border: 4px solid var(--ink); border-radius: 10px; animation: rot 1.8s ease-in-out infinite; }
  @keyframes rot { 50% { transform: rotate(-90deg); } }
}

/* telas baixas */
@media (max-height: 640px) {
  .pbar.opp { padding: 5px 10px; }
  .avatar { width: 32px; height: 32px; font-size: 15px; }
  .pile { transform: scale(.85); }
  .center-strip { padding: 2px 14px; }
  .actions { min-height: 54px; padding: 6px 10px; }
}

/* ===== 3 vermelhos em destaque ===== */
.meld.red3s { background: rgba(212,42,58,.16); box-shadow: 0 0 0 2px rgba(255,120,130,.75), 0 0 16px rgba(212,42,58,.55); animation: red3Glow 2.4s ease-in-out infinite; }
@keyframes red3Glow { 50% { box-shadow: 0 0 0 2px rgba(255,120,130,.9), 0 0 6px rgba(212,42,58,.35); } }
.meld.red3s .badge { font-size: 10px; }
.meld.red3s.pos .badge { background: var(--ok); color: #053016; }
.meld.red3s.neg .badge { background: #ff6b78; color: #3a0007; }

/* ===== canastra fechada ===== */
.meld.closed { cursor: pointer; }
.meld.closed .card.layer { position: absolute; z-index: 3; background: linear-gradient(160deg, #fff, #ece4cf); box-shadow: 0 1px 2px rgba(0,0,0,.35), inset 0 0 0 1px rgba(0,0,0,.1); }
.meld.closed .card.layer:nth-of-type(1) { z-index: 2; }
.meld.closed .card.top { z-index: 5; box-shadow: 0 2px 6px rgba(0,0,0,.4), inset 0 0 0 1px rgba(0,0,0,.08); }
.meld.closed .card.wild-cross { z-index: 1; transform: rotate(-90deg) scale(.72); transform-origin: 50% 50%; box-shadow: 0 0 0 1.5px var(--dirty), 0 2px 6px rgba(0,0,0,.4); }
.meld.closed .card.top .cc { opacity: .18; }
.meld.closed.clean .card.top { box-shadow: 0 0 0 1.5px var(--clean), 0 2px 8px rgba(0,0,0,.45); }
.meld .range {
  position: absolute; z-index: 6; left: 50%; top: calc(var(--cw) * .82); transform: translateX(-50%);
  font-size: calc(var(--cw) * .24); font-weight: 900; white-space: nowrap; padding: 1px 5px; border-radius: 6px;
  background: rgba(10, 30, 22, .88); color: #fff; letter-spacing: .3px; font-family: -apple-system, Roboto, sans-serif;
}
.meld .range .rs { color: #ff7d89; }
.meld.closing { animation: closeIn .7s var(--ease); }
@keyframes closeIn {
  0% { transform: scaleY(1.9) translateY(-20%); filter: brightness(1.6); }
  45% { transform: scaleY(.88); }
  70% { transform: scale(1.08); }
  100% { transform: none; }
}
.meld.canastra:not(.closed) { cursor: pointer; }

/* ===== mortos no cantinho ===== */
.center-strip { padding-left: 8px; padding-right: 12px; }
.mortos { flex: none; width: 58px; display: flex; flex-direction: column; gap: 3px; align-items: center; }
.morto-slot { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.mstack { position: relative; width: 46px; height: 31px; }
.mstack .card { --cw: 28px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(90deg); }
.mstack .card:nth-child(2) { transform: translate(-50%, calc(-50% - 3px)) rotate(90deg); box-shadow: inset 0 0 0 2px #fff, 0 0 0 1.5px var(--gold), 0 0 10px rgba(242,193,78,.55), 0 2px 5px rgba(0,0,0,.4); }
.morto-slot.taken .mstack { border: 1.5px dashed rgba(255,255,255,.2); border-radius: 6px; display: grid; place-items: center; }
.mcheck { color: var(--ok); font-weight: 900; font-size: 15px; }
.mlabel { font-size: 9px; text-transform: uppercase; letter-spacing: .4px; color: var(--gold); font-weight: 800; max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.morto-slot.taken .mlabel { color: var(--muted); }
.morto-fly { position: absolute; width: 46px; height: 31px; z-index: 160; }
.morto-fly .card { --cw: 28px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(90deg); }
.morto-fly.down { animation: mortoDown .9s var(--ease) forwards; }
.morto-fly.up { animation: mortoUp .9s var(--ease) forwards; }
@keyframes mortoDown { 30% { transform: scale(1.3); } 100% { transform: translate(120px, 340px) scale(1.8); opacity: 0; } }
@keyframes mortoUp { 30% { transform: scale(1.3); } 100% { transform: translate(120px, -280px) scale(.8); opacity: 0; } }

/* ===== destaque central do 3 vermelho ===== */
.spotlight { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 10px; animation: spotIn .45s var(--ease); z-index: 170; }
.spotlight::before { content: ""; position: absolute; left: 50%; top: 45%; width: 200vmax; height: 200vmax; transform: translate(-50%, -50%); background: radial-gradient(circle, rgba(120,10,22,.75) 0, rgba(0,0,0,.6) 18vmax, rgba(0,0,0,.35) 45vmax); z-index: -1; }
.spotlight.out { animation: spotOut .35s forwards; }
.spotlight.opp.out { --dir: -160px; } .spotlight.me.out { --dir: 160px; }
@keyframes spotIn { from { transform: translate(-50%, -50%) scale(.3); opacity: 0; } }
@keyframes spotOut { to { transform: translate(-50%, calc(-50% + var(--dir, 0px))) scale(.4); opacity: 0; } }
.spot-fan { display: flex; }
.spot-card { margin: 0 -18px; transform: rotate(var(--rot)); animation: spotCard .5s var(--ease) both; animation-delay: var(--d); }
.spot-card .card { --cw: 86px; position: relative; box-shadow: 0 0 0 3px #ff7d89, 0 0 30px rgba(212,42,58,.8), 0 10px 26px rgba(0,0,0,.5); }
@keyframes spotCard { from { transform: rotate(var(--rot)) translateY(40px) scale(.6); opacity: 0; } }
.spot-text { font-weight: 900; font-size: 18px; text-shadow: 0 2px 10px rgba(0,0,0,.8); white-space: nowrap; }
.spot-val { font-weight: 900; font-size: 22px; padding: 4px 14px; border-radius: 14px; }
.spot-val small { font-size: 12px; font-weight: 700; }
.spot-val.pos { background: var(--ok); color: #053016; }
.spot-val.neg { background: #ff6b78; color: #3a0007; }

.btn.off { opacity: .42; filter: grayscale(.7); box-shadow: none; }
.pile.lixo.disabled .lixo-slot .card { filter: grayscale(.5) brightness(.85); }

/* ===== jogadores (1x1 e duplas) ===== */
.opp-chips { flex: 1; min-width: 0; display: flex; gap: 8px; }
.pchip { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; padding: 2px 4px; border-radius: 12px; transition: background .3s; }
.pchip.turn { background: rgba(242,193,78,.12); }
.opp-chips.four .pchip .avatar { width: 30px; height: 30px; font-size: 14px; }
.opp-chips.four .pchip .pname { font-size: 13px; }
.avatar.bot { background: linear-gradient(135deg, #3a8f9a, #1d5560); }
.bot-tag { font-size: 12px; }
.partner { flex: none; max-width: 42%; }
.partner .pchip { padding: 2px 8px 2px 2px; background: rgba(0,0,0,.18); }
.partner .pchip.turn { background: rgba(242,193,78,.16); }
.partner .avatar { width: 28px; height: 28px; font-size: 13px; }
.partner .pname { font-size: 12.5px; }

/* ===== sala de espera: lugares ===== */
.seats { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.team-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.team-box.team-0 { border-color: rgba(74,222,128,.35); }
.team-box.team-1 { border-color: rgba(143,184,255,.35); }
.team-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); padding: 2px 4px; font-weight: 700; }
.seat-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.04); }
.seat-card.mine { background: rgba(242,193,78,.12); box-shadow: inset 0 0 0 1px rgba(242,193,78,.4); }
.seat-card.empty .avatar { background: transparent; border: 2px dashed rgba(255,255,255,.25); color: var(--muted); }
.seat-card .avatar { width: 36px; height: 36px; }
.seat-info { flex: 1; min-width: 0; }
.seat-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-tag { font-size: 12px; color: var(--muted); }
.seat-actions { display: flex; gap: 6px; flex: none; }
.mini-btn { padding: 7px 11px; border-radius: 10px; font-size: 13px; font-weight: 700; background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #3b2500; }
.mini-btn.ghost { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
.mini-btn:active { transform: scale(.95); }
.lobby-hint { font-size: 13px; color: var(--muted); min-height: 0; }
.lobby-wrap .btn.full { max-width: 420px; }
.lobby-wrap { justify-content: flex-start; padding-top: 24px; }
.lobby-wrap .qr { width: 150px; height: 150px; }
.room-code { font-size: 46px; }

.mate { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; }
.mate-av { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: linear-gradient(135deg, #6d5bd0, #3c2f8f); border: 1.5px solid rgba(255,255,255,.3); flex: none; }
.mate-av.bot { background: linear-gradient(135deg, #3a8f9a, #1d5560); }
.mate.turn .mate-av { box-shadow: 0 0 0 2px var(--gold), 0 0 10px var(--gold); animation: pulse 1.6s infinite; }
.mate-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; font-size: 14px; }
.mate-cards { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 700; }

/* ===== duplas: parceiro em cima, adversários nas laterais ===== */
.side-seat { display: none; }
#screen-game.four .side-seat { display: flex; flex: none; width: 52px; justify-content: center; }
#screen-game.four .center-strip { padding-left: 2px; padding-right: 2px; gap: 4px; }
#screen-game.four .center-strip .pile { transform: scale(.84); margin: 0 -5px; }
#screen-game.four .mortos { width: 46px; }
#screen-game.four .mstack { transform: scale(.88); }
#screen-game.four .turn-text { font-size: 13.5px; }
#screen-game.four .target-text { font-size: 10.5px; color: var(--gold); opacity: .85; }
#screen-game.four .me .score-box { display: none; }
.side-chip { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; border-radius: 12px; width: 52px; transition: background .3s; }
.side-chip .avatar { width: 34px; height: 34px; font-size: 15px; position: relative; }
.side-chip.turn { background: rgba(242,193,78,.14); }
.side-chip.turn .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 16px var(--gold); animation: pulse 1.6s infinite; }
.side-chip.next .avatar { box-shadow: 0 0 0 2px rgba(242,193,78,.45); }
.side-mark { position: absolute; right: -7px; bottom: -5px; font-size: 12px; }
.side-name { font-size: 10.5px; font-weight: 700; max-width: 52px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-cards { font-size: 11px; font-weight: 800; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.side-next { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: #3b2500; background: var(--gold); border-radius: 6px; padding: 0 5px; }
#screen-game.four .opp-chips { justify-content: center; }
#screen-game.four .opp-chips .pchip { flex: 0 1 auto; padding-right: 12px; }
#screen-game.four #opp-score { font-size: 18px; white-space: nowrap; }
.sc-us { color: var(--ok); } .sc-x { color: var(--muted); font-size: 13px; margin: 0 4px; } .sc-them { color: var(--gold); }

.warn-go { color: var(--bad); font-weight: 800; text-transform: none; letter-spacing: 0; }
#screen-game.four .opp-chips { min-width: 0; overflow: hidden; }
#screen-game.four .opp-chips .pchip { flex: none; max-width: 100%; padding-right: 10px; }
#screen-game.four .opp-chips .pchip .pinfo { flex: none; min-width: 0; max-width: 150px; }
#screen-game.four .opp-chips .pchip .pname { overflow: visible; }
#screen-game.four .opp-chips .pchip .pname span { display: block; flex: 0 1 auto; min-width: 0; max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#screen-game.four .opp-chips .pchip .pstats { flex-wrap: nowrap; }
#screen-game.four .score-box { flex: none; max-width: 110px; }
.warn-go { display: block; white-space: normal; line-height: 1.1; font-size: 10px; }
.meld .badge { font-size: clamp(7px, calc(var(--cw) * .2), 9px); padding: 1px 4px; letter-spacing: .2px; }
