:root {
  --bg: #0b1510; --panel: #14231b; --panel2: #1b2f24; --line: #2a4536;
  --text: #eef5f0; --muted: #8fa89a; --gold: #e8c05a; --green: #2fbf71; --red: #e5484d; --blue: #3b82f6;
  --felt1: #1f7a4d; --felt2: #0f4a2d; --rail: #4a2f1b;
  --seat-w: 96px; --card-w: 50px; --mini-w: 30px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.hidden { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.sm-text { font-size: 12px; }
button, input, select { font: inherit; color: inherit; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.center-screen { align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 50% 30%, #1d4a33, var(--bg) 70%); }
.card-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.login-box { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.logo { font-size: 26px; letter-spacing: 1px; } .logo b { color: var(--gold); }
.logo.small { font-size: 18px; }

input, select { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: 100%; outline: none; }
input:focus, select:focus { border-color: var(--green); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; cursor: pointer; background: var(--panel2); transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--green); color: #052013; }
.btn.danger { background: var(--red); color: #fff; }
.btn.warn { background: var(--gold); color: #2b1d00; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.sm { padding: 8px 12px; font-size: 14px; }
.btn.big { padding: 14px; font-size: 17px; }
.btn:hover:not(:disabled) { filter: brightness(1.1); }

.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line); z-index: 5; }
.pill { background: var(--panel2); padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.tinfo { display: flex; flex-direction: column; line-height: 1.2; font-size: 14px; }
.tinfo .muted { font-size: 12px; }

/* LOBBY */
.lobby-main { flex: 1; overflow: auto; padding: 16px; max-width: 900px; width: 100%; margin: 0 auto; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.lobby-head h2 { margin: 0; }
.table-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.tcard h3 { margin: 0; font-size: 18px; display: flex; justify-content: space-between; }
.tcard .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tcard .dots { display: flex; gap: 4px; margin: 4px 0; }
.tcard .dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); }
.tcard .dots i.on { background: var(--green); border-color: var(--green); }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; grid-column: 1/-1; }

/* MESA */
.table-area { position: relative; flex: 1; min-height: 0; margin: 0 auto; width: 100%; max-width: 1100px; }
.felt { position: absolute; inset: 9% 3% 9% 3%; border-radius: 50%; background: var(--rail);
  box-shadow: 0 14px 40px rgba(0,0,0,.6), inset 0 0 0 2px rgba(255,255,255,.06); padding: 12px; }
.felt-inner { width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, var(--felt1), var(--felt2) 75%); box-shadow: inset 0 0 40px rgba(0,0,0,.55); }
.center { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 2; width: 70%; pointer-events: none; }
.potbox { font-weight: 700; color: var(--gold); background: rgba(0,0,0,.4); padding: 4px 14px; border-radius: 999px; font-size: 15px; min-height: 26px; }
.board { display: flex; gap: 6px; min-height: calc(var(--card-w) * 1.4); }
.banner { text-align: center; font-size: 14px; font-weight: 600; min-height: 20px; text-shadow: 0 1px 3px #000; max-width: 100%; }
.banner .win { color: var(--gold); display: block; }
.banner .hint { color: #cfe5d6; font-weight: 500; }

/* Cartas */
.card { width: var(--card-w); aspect-ratio: 5/7; background: #fbfbf8; border-radius: 6px; color: #15171a; position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,.5); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; line-height: 1; animation: deal .3s ease-out both; }
.card .r { font-size: calc(var(--card-w) * .46); }
.card .s { font-size: calc(var(--card-w) * .5); }
.card.red { color: #d62839; }
.card.back { background: repeating-linear-gradient(45deg, #274690, #274690 4px, #1d3570 4px, #1d3570 8px); border: 2px solid #fff; }
.card.win { outline: 3px solid var(--gold); transform: translateY(-4px); box-shadow: 0 0 14px var(--gold); }
.card.dim { opacity: .55; }
.card.mini { --card-w: var(--mini-w); }
@keyframes deal { from { opacity: 0; transform: translateY(-14px) scale(.9); } to { opacity: 1; transform: none; } }

/* Asientos */
.seat { position: absolute; transform: translate(-50%, -50%); width: var(--seat-w); display: flex; flex-direction: column; align-items: center; z-index: 3; transition: opacity .2s; }
.seat .hole { display: flex; gap: 2px; margin-bottom: -10px; z-index: 1; min-height: 20px; }
.seat.me .hole { margin-bottom: -14px; }
.seat .hole .card { --card-w: var(--mini-w); }
.seat.me .hole .card { --card-w: 46px; }
.plate { width: 100%; background: linear-gradient(#25392e, #172820); border: 2px solid var(--line); border-radius: 12px; padding: 14px 6px 5px; text-align: center; position: relative; box-shadow: 0 3px 10px rgba(0,0,0,.5); }
.seat .name { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .stack { font-size: 13px; color: var(--gold); font-weight: 700; }
.seat .tag { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); min-height: 12px; }
.seat.me .plate { border-color: var(--green); }
.seat.turn .plate { border-color: var(--gold); box-shadow: 0 0 16px rgba(232,192,90,.7); }
.seat.folded { opacity: .45; }
.seat.away .plate { filter: grayscale(.8); }
.seat.winner .plate { border-color: var(--gold); box-shadow: 0 0 22px var(--gold); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 34px var(--gold); } }
.tbar { position: absolute; left: 6px; right: 6px; bottom: -6px; height: 5px; background: rgba(0,0,0,.6); border-radius: 3px; overflow: hidden; display: none; }
.seat.turn .tbar { display: block; }
.tbar i { display: block; height: 100%; width: 100%; background: var(--green); }
.dbtn { position: absolute; right: -8px; top: -4px; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #111; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px #000; z-index: 4; }
.empty-seat { width: 74px; height: 50px; border: 2px dashed rgba(255,255,255,.25); border-radius: 12px; background: rgba(0,0,0,.25); color: #d4e8dc; font-size: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.empty-seat:hover { background: rgba(0,0,0,.45); }
.empty-seat.lock { cursor: default; opacity: .4; }
.bet { position: absolute; transform: translate(-50%, -50%); z-index: 2; display: flex; align-items: center; gap: 4px; background: rgba(0,0,0,.55); border-radius: 999px; padding: 2px 10px 2px 3px; font-size: 12px; font-weight: 700; animation: deal .25s both; }
.bet::before { content: ''; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle, #fff 0 22%, var(--red) 24% 60%, #fff 62% 70%, var(--red) 72%); }

/* Acciones */
.actions { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; min-height: 72px; justify-content: center; }
.actions .row { display: flex; gap: 8px; justify-content: center; }
.actions .row .btn { flex: 1; max-width: 220px; padding: 14px 8px; font-size: 16px; }
.raise-panel { display: flex; flex-direction: column; gap: 8px; max-width: 640px; width: 100%; margin: 0 auto; }
.raise-line { display: flex; gap: 8px; align-items: center; }
.raise-line input[type=range] { flex: 1; accent-color: var(--gold); padding: 0; height: 28px; background: none; border: 0; }
.raise-line input[type=number] { width: 100px; text-align: center; font-weight: 700; padding: 8px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.quick button { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.status-line { text-align: center; color: var(--muted); font-size: 14px; }
.myhand { color: var(--gold); font-weight: 700; }

/* Panel lateral */
.side { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100%); background: var(--panel); border-left: 1px solid var(--line); transform: translateX(100%); transition: transform .25s; z-index: 20; display: flex; flex-direction: column; }
.side.open { transform: none; }
.side-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); align-items: center; padding-top: max(10px, env(safe-area-inset-top)); }
.tab { background: transparent; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; cursor: pointer; }
.tab.active { background: var(--panel2); color: var(--text); }
.side-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.msg b { color: var(--gold); }
.logline { color: #c3d6ca; font-size: 13px; }
.logline.h { color: var(--gold); font-weight: 700; margin-top: 6px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.badge { background: var(--red); border-radius: 999px; padding: 1px 6px; font-size: 11px; }

/* Modal / toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 50; overflow: auto; }
.modal-box { width: min(480px, 100%); display: flex; flex-direction: column; gap: 12px; max-height: 100%; overflow: auto; }
.modal-box h3 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.end { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: #000d; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 99; pointer-events: none; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--red); }

/* Móvil */
@media (max-width: 700px) {
  :root { --seat-w: 76px; --card-w: 38px; --mini-w: 24px; }
  .felt { inset: 6% 2% 6% 2%; padding: 8px; }
  .seat .name { font-size: 11px; }
  .seat .stack { font-size: 12px; }
  .seat.me .hole .card { --card-w: 40px; }
  .plate { padding: 12px 4px 4px; }
  .center { width: 62%; }
  .banner { font-size: 12px; }
  .empty-seat { width: 56px; height: 40px; font-size: 11px; }
  .actions .row .btn { font-size: 15px; padding: 13px 4px; }
  .bet { font-size: 11px; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-height: 560px) and (orientation: landscape) {
  :root { --seat-w: 80px; --card-w: 34px; --mini-w: 22px; }
  .actions { padding: 6px 10px; }
  .actions .row .btn { padding: 9px 4px; }
}
