:root {
  --bg: #efe8da; --panel: #fffdf7; --ink: #23201b; --muted: #6f685d; --line: #ddd2bd;
  --felt-1: #2f7a57; --felt-2: #1c4d37; --felt-ink: #f4f1e8; --wood-1: #8a5a33; --wood-2: #5b3a20;
  --accent: #b4452a; --accent-ink: #fff; --gold: #e2b33c; --ok: #2f7d4f; --bad: #b3261e; --focus: #2f6db5;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 6px 18px rgba(0,0,0,.08);
  --card-w: 96px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --panel: #1c2026; --ink: #ece8df; --muted: #a39d92; --line: #323840;
    --felt-1: #24654a; --felt-2: #123526; --wood-1: #6b4426; --wood-2: #3f2814;
    --accent: #e0714d; --accent-ink: #14171b; --ok: #5cbf86; --bad: #f2786d; --focus: #8ab4f8;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
header { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 10; }
h1 { font-family: Cinzel, Georgia, serif; font-size: 20px; margin: 0; letter-spacing: .5px; display: flex; align-items: center; gap: 10px; }
.mode { font-family: Inter, system-ui, sans-serif; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--felt-2); color: var(--felt-ink); letter-spacing: 0; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.group { display: inline-flex; align-items: center; gap: 4px; }
button, select, input { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 7px 13px; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
button.icon { padding: 7px 11px; min-width: 36px; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.lift { background: #2a2622; color: #fff; border-color: #2a2622; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.lift { background: #f4f1e8; color: #1c2026; border-color: #f4f1e8; } }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
select, input[type=number] { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 6px 9px; }
label.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
label.check[hidden] { display: none; }
main { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; padding: 18px; max-width: 1400px; margin: 0 auto; }
/* Dos columnas solo si cabe el tapete entero (800 px de ancho a su altura mínima) junto al registro. */
@media (max-width: 1200px) { main { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.hint { font-size: 13px; color: var(--muted); }

/* --- La mesa --- */
.felt { position: relative; aspect-ratio: 16 / 10; min-height: 500px; border-radius: 48% / 44%;
  background: radial-gradient(ellipse at 50% 42%, var(--felt-1) 0%, var(--felt-2) 78%);
  border: 16px solid var(--wood-1); box-shadow: inset 0 0 0 3px rgba(0,0,0,.25), inset 0 0 60px rgba(0,0,0,.35), 0 0 0 4px var(--wood-2), var(--shadow);
  color: var(--felt-ink); }
.felt::after { content: ""; position: absolute; inset: 7%; border: 2px dashed rgba(255,255,255,.12); border-radius: 48% / 44%; pointer-events: none; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px; font-size: 16px; opacity: .9; }
.seat { position: absolute; transform: translate(-50%, -50%); width: 200px; display: flex; flex-direction: column; align-items: center; gap: 5px; z-index: 2; }
.seat .head { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.4); border-radius: 99px; padding: 4px 6px 4px 4px; max-width: 100%; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; border: 2px solid rgba(255,255,255,.85); box-shadow: 0 2px 8px rgba(0,0,0,.35); position: relative; }
.seat.turn .avatar { animation: glow 1.4s ease-in-out infinite; border-color: var(--gold); }
.seat.turn .head { box-shadow: 0 0 0 2px var(--gold); }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(226,179,60,.85); } 50% { box-shadow: 0 0 0 9px rgba(226,179,60,0); } }
.seat .plate { text-align: left; min-width: 0; padding-right: 4px; }
.seat .who { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.seat .meta { font-size: 12px; opacity: .85; line-height: 1.2; }
.seat .fan { display: flex; justify-content: center; height: 40px; }
.seat .fan .naipe { width: 27px; margin-left: -19px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.seat .fan .naipe:first-child { margin-left: 0; }
.seat .open { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; max-width: 230px; }
.seat .open .naipe { width: 30px; }
.seat .eye { flex: none; font-size: 15px; line-height: 1; width: 30px; height: 30px; padding: 0; border-radius: 50%; background: rgba(255,255,255,.12); color: var(--felt-ink); border-color: rgba(255,255,255,.3); }
.seat .eye.on { background: var(--gold); color: #2b2100; border-color: var(--gold); }
.medal { position: absolute; top: -6px; right: -10px; background: var(--gold); color: #2b2100; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 6px; border: 2px solid #fff; }
.bubble { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); background: #fffdf7; color: #23201b; font-weight: 650; font-size: 13px; padding: 3px 10px; border-radius: 12px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.35); animation: pop .25s ease-out; }
.bubble::after { content: ""; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fffdf7; border-bottom: 0; }
.bubble.lift { background: var(--gold); }
.bubble.lift::after { border-top-color: var(--gold); }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

.center { position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%); width: min(46%, 380px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 1; }
.round { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.32); border-radius: 99px; padding: 4px 14px 4px 6px; }
.round .naipe { width: 30px; }
.round .label { font-size: 12px; opacity: .85; line-height: 1.1; }
.round .rank { font-family: Cinzel, Georgia, serif; font-size: 22px; font-weight: 700; line-height: 1.1; }
.pile { position: relative; width: 210px; height: 150px; }
.pile .stack { position: absolute; left: 50%; top: 50%; }
.pile .stack .naipe { position: absolute; width: 74px; left: -37px; top: -57px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.pile .last { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; }
.pile .last .naipe { width: 78px; margin-left: -34px; filter: drop-shadow(0 3px 6px rgba(0,0,0,.45)); }
.pile .last .naipe:first-child { margin-left: 0; }
.pile .reveal .naipe { animation: flip .5s ease-out both; }
.pile .reveal .naipe:nth-child(2) { animation-delay: .08s; }
.pile .reveal .naipe:nth-child(3) { animation-delay: .16s; }
@keyframes flip { from { transform: perspective(400px) rotateY(90deg); } to { transform: perspective(400px) rotateY(0); } }
.stamp { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-12deg); font-family: Cinzel, Georgia, serif; font-weight: 700; font-size: 26px; letter-spacing: 2px; padding: 2px 14px; border: 4px solid currentColor; border-radius: 8px; background: rgba(255,253,247,.88); pointer-events: none; animation: stamp .35s .3s ease-out both; }
.stamp.lie { color: var(--bad); }
.stamp.truth { color: var(--ok); }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-12deg) scale(2); opacity: 0; } to { transform: translate(-50%, -50%) rotate(-12deg) scale(1); opacity: 1; } }
.caption { font-size: 13px; text-align: center; background: rgba(0,0,0,.32); padding: 4px 12px; border-radius: 10px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.discards { position: absolute; right: 7%; bottom: 9%; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 11px; opacity: .9; z-index: 1; }
.discards .row { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; max-width: 150px; }
.discards .naipe { width: 20px; }

/* --- Tu mano --- */
.dock { margin-top: 16px; padding: 16px; }
.dock h2, .log h2, .end h2 { font-family: Cinzel, Georgia, serif; font-size: 16px; margin: 0 0 8px; letter-spacing: .3px; }
.status { font-weight: 650; margin-bottom: 10px; min-height: 22px; }
.status.yours { color: var(--accent); }
.hand { display: flex; justify-content: center; padding: 24px 10px 8px; min-height: 170px; --step: calc(var(--card-w) * 0.72); }
.hand .slot { margin-left: calc(var(--step) - var(--card-w)); transition: transform .15s; position: relative; }
.hand .slot:first-child { margin-left: 0; }
.hand button.slot { border: 0; padding: 0; background: none; border-radius: 9px; }
.hand .slot .naipe { width: var(--card-w); filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
.hand button.slot:hover:not(:disabled) { transform: translateY(-8px); }
.hand .slot.picked { transform: translateY(-22px); }
.hand .slot.picked .naipe { filter: drop-shadow(0 0 0 var(--gold)) drop-shadow(0 0 6px var(--gold)); }
.hand .slot.match::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--accent); }
.hand button.slot:disabled { cursor: default; opacity: 1; }
.declare { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.declare button { padding: 5px 10px; border-radius: 99px; }
.declare button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.verdict { font-size: 13px; font-weight: 600; }
.verdict.lie { color: var(--bad); }
.verdict.truth { color: var(--ok); }
.watched { display: grid; gap: 14px; }
.watched .who { font-weight: 650; margin-bottom: 4px; }
.watched .cards { display: flex; flex-wrap: wrap; gap: 4px; }
.watched .naipe { width: 54px; }

/* --- Registro --- */
.log { padding: 14px; max-height: calc(100vh - 100px); overflow: auto; position: sticky; top: 76px; }
@media (max-width: 1200px) { .log { position: static; max-height: 420px; } }
.log ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.log li { font-size: 13px; padding: 7px 9px; border-radius: 10px; border-left: 3px solid var(--line); background: color-mix(in srgb, var(--panel) 92%, var(--ink)); }
.log li.lift { border-left-color: var(--accent); }
.log li .t { color: var(--muted); font-size: 11px; margin-right: 6px; }
.log li .real { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; }
.log li .real .naipe { width: 20px; }
.lie-tag { color: var(--bad); font-weight: 650; }
.truth-tag { color: var(--ok); font-weight: 650; }

/* --- Resultado --- */
.end { margin-top: 16px; padding: 16px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
.scroll { overflow-x: auto; }

/* --- Ventana de nueva partida --- */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); padding: 20px; width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog a { color: var(--focus); }
dialog h2 { font-family: Cinzel, Georgia, serif; margin: 0 0 10px; font-size: 20px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.segmented label { padding: 7px 16px; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.field { display: grid; gap: 4px; margin: 10px 0; }
.field small { color: var(--muted); }
.pickhead { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; justify-content: space-between; margin-top: 12px; }
.rivalpick { display: grid; gap: 10px; margin-top: 8px; }
.rivalpick .row { display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; align-items: center; }
.rivalpick .row label { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.rivalpick .row small { grid-column: 1 / -1; }
.rivalpick select { width: 100%; }
.row2 { display: flex; flex-wrap: wrap; gap: 12px; }
dialog.deck { width: min(1000px, calc(100vw - 32px)); }
#deckCards { display: grid; gap: 10px; margin-top: 8px; }
#deckCards .suit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#deckCards .suit b { width: 70px; font-family: Cinzel, Georgia, serif; }
#deckCards .naipe { width: 64px; }
/* --- Cartas en vuelo: jugadas, montón que se recoge y cuádruples descartados --- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
#fx .naipe { position: fixed; left: 0; top: 0; transform-origin: 50% 50%; filter: drop-shadow(0 4px 8px rgba(0,0,0,.45)); will-change: transform, opacity; }
#fx .badge { position: fixed; left: 0; top: 0; background: var(--gold); color: #2b2100; font-weight: 700; font-size: 15px; padding: 2px 11px; border-radius: 99px; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); white-space: nowrap; }
#fx .badge.bad { background: var(--bad); color: #fff; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 9px 15px; border-radius: 10px; box-shadow: var(--shadow); display: none; max-width: calc(100vw - 32px); z-index: 20; }

/* --- Pantallas estrechas: los asientos pasan a una cuadrícula sobre el tapete --- */
@media (max-width: 760px) {
  :root { --card-w: 64px; }
  header { padding: 10px 12px; }
  main { padding: 12px; }
  .felt { aspect-ratio: auto; min-height: 0; border-radius: 26px; border-width: 10px; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 30px 8px; padding: 36px 10px 14px; }
  .felt::after { inset: 4px; border-radius: 20px; }
  .seat { position: static; transform: none; width: auto; min-width: 0; }
  .seat.me { display: none; }
  .center { position: static; transform: none; width: auto; grid-column: 1 / -1; }
  .discards { position: static; grid-column: 1 / -1; align-items: center; }
  .discards .row { justify-content: center; max-width: none; }
  .empty { position: static; grid-column: 1 / -1; }
}
