/* MUS.ST — identidad: mesa de Mus tradicional + universidad. Nada de casino. */
:root {
  --bg: #f4eee2;
  --surface: #fffcf5;
  --surface-2: #efe6d3;
  --fg: #1d2420;
  --muted: #5d625b;
  --line: #d9ccb3;
  --felt: #1f4d3a;
  --felt-2: #173d2e;
  --felt-line: #2d6a51;
  --wood: #5a3a24;
  --accent: #7a1f2b;      /* granate */
  --accent-fg: #fff8ef;
  --gold: #a8842c;        /* oro viejo */
  --team-a: #1f5f8b;
  --team-b: #8b3a1f;
  --ok: #2f6b3a;
  --warn: #8a5a00;
  --card: #fbf6ea;
  --card-line: #cdbf9f;
  --shadow: 0 1px 2px rgb(0 0 0 / .08), 0 6px 18px rgb(40 30 10 / .10);
  --radius: 12px;
  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --text-scale: 1;
  --speed: 1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111613; --surface: #18201c; --surface-2: #1f2924; --fg: #ece5d6;
    --muted: #a7aca2; --line: #2f3a34; --felt: #173a2c; --felt-2: #112c21; --felt-line: #275a45;
    --accent: #c46a76; --accent-fg: #1a0f11; --gold: #d2b25c; --team-a: #74b0da; --team-b: #e49a7d;
    --card: #ece3cf; --card-line: #9f9277; --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111613; --surface: #18201c; --surface-2: #1f2924; --fg: #ece5d6; --muted: #a7aca2;
  --line: #2f3a34; --felt: #173a2c; --felt-2: #112c21; --felt-line: #275a45;
  --accent: #c46a76; --accent-fg: #1a0f11; --gold: #d2b25c; --team-a: #74b0da; --team-b: #e49a7d;
  --card: #ece3cf; --card-line: #9f9277; --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .35);
  color-scheme: dark;
}
:root[data-table="granate"] { --felt: #5b1f27; --felt-2: #48171e; --felt-line: #7a3540; }
:root[data-table="azul"] { --felt: #1d3a5c; --felt-2: #162e49; --felt-line: #2e5480; }

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--text-scale)); }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-sans);
  line-height: 1.5; min-height: 100vh; overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }
.skip:focus { left: 8px; }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 700; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h3, .card-title { font-size: 1.3rem; }
.page-title { font-size: clamp(1.5rem, 4vw, 2.1rem); }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------------ cabecera */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; text-align: left; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px; background: var(--felt); color: #f3ead7;
  display: grid; place-items: center; font-family: var(--font-serif); font-size: 1.4rem; font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--gold);
}
.brand-text strong { display: block; font-family: var(--font-serif); font-size: 1.35rem; letter-spacing: .04em; }
.brand-text small { display: block; color: var(--muted); font-size: .72rem; margin-top: -2px; }
.topnav { display: flex; gap: 4px; margin-left: auto; }
.topnav button, .pill, .icon-btn {
  background: none; border: 1px solid transparent; border-radius: 999px; padding: 6px 12px; font-weight: 500;
}
.topnav button:hover, .topnav button[aria-current="page"] { border-color: var(--line); background: var(--surface-2); }
.top-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { padding: 6px 9px; }
.pill { border-color: var(--line); }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .topnav { order: 3; width: 100%; justify-content: space-between; margin: 0; }
  .brand-text small { display: none; }
  .top-actions { margin-left: auto; }
}

/* ------------------------------------------------------------------ páginas */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.hero { display: grid; gap: 24px; grid-template-columns: 1.2fr 1fr; align-items: center; padding: 16px 0 28px; }
.hero p { font-size: 1.1rem; color: var(--muted); max-width: 46ch; }
.hero-table {
  aspect-ratio: 4 / 3; border-radius: 50% / 40%; background: radial-gradient(ellipse at center, var(--felt-line), var(--felt) 60%, var(--felt-2));
  border: 10px solid var(--wood); box-shadow: var(--shadow); display: grid; place-items: center;
}
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero-table { display: none; } }
.pillars { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.panel h3, .panel .card-title { display: flex; align-items: center; gap: 8px; }
.panel .kicker { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.stack { display: grid; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 600;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.ghost { background: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
label.field { display: grid; gap: 4px; font-weight: 500; font-size: .92rem; }
.field input, .field select { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child, table.data td.l, table.data th.l { text-align: left; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; border: 1px solid var(--line); background: var(--surface-2); }
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: var(--accent); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ------------------------------------------------------------------ mesa */
.game { max-width: 1100px; margin: 0 auto; padding: 12px 16px 24px; display: grid; gap: 12px; }
.scorebar {
  position: sticky; top: 0; z-index: 4;
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
}
.lances { display: flex; gap: 4px; flex-wrap: wrap; }
.lance { padding: 3px 10px; border-radius: 999px; font-size: .8rem; border: 1px solid var(--line); color: var(--muted); }
.lance.current { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.lance.done { text-decoration: line-through; opacity: .7; }
.lance.current::before { content: "▶ "; }
.scores { display: grid; gap: 2px; font-size: .9rem; }
.score-line { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.score-line .team-dot { width: 10px; height: 10px; border-radius: 2px; }
.score-line strong { font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; font-size: 1.6rem; }
.scores { font-size: 1rem; }
.amarracos { display: inline-flex; gap: 2px; }
.amarraco { width: 7px; height: 16px; border-radius: 2px; background: var(--gold); }
.piedra { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); align-self: center; }
.dentro { font-size: .7rem; padding: 0 6px; border-radius: 999px; background: var(--warn); color: #fff; }

.table {
  position: relative; display: grid; gap: 8px;
  grid-template-areas: ". top ." "left center right" ". bottom .";
  grid-template-columns: minmax(90px, 1fr) minmax(0, 2.2fr) minmax(90px, 1fr);
  background: radial-gradient(ellipse at center, var(--felt-line), var(--felt) 55%, var(--felt-2));
  border: 10px solid var(--wood); border-radius: 28px; padding: 14px; box-shadow: var(--shadow); color: #f3ead7;
  min-height: 360px;
}
.seat { display: grid; justify-items: center; gap: 4px; align-content: center; position: relative; }
.seat.top { grid-area: top; } .seat.left { grid-area: left; } .seat.right { grid-area: right; } .seat.bottom { grid-area: bottom; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem;
  background: #f3ead7; color: #1d2420; border: 3px solid var(--team-color, var(--gold)); position: relative;
}
.seat.turn .avatar { box-shadow: 0 0 0 4px var(--gold); }
.seat.turn .avatar::after { content: "⏳"; position: absolute; right: -10px; top: -8px; font-size: 1rem; }
.seat-name { font-weight: 600; font-size: .9rem; text-align: center; }
.seat-meta { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.chip { font-size: .7rem; padding: 0 6px; border-radius: 999px; background: rgb(0 0 0 / .28); border: 1px solid rgb(255 255 255 / .25); }
.chip.mano { background: var(--gold); color: #1d2420; border-color: var(--gold); }
.chip.si { background: #2f6b3a; } .chip.no { background: rgb(0 0 0 / .35); }
.backs { display: flex; gap: 2px; }
.back { width: 18px; height: 26px; border-radius: 3px; background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 3px, #5a1620 3px, #5a1620 6px); border: 1px solid #f3ead7; }
:root[data-back="liso"] .back { background: var(--accent); }
:root[data-back="escudo"] .back { background: radial-gradient(circle, var(--gold) 30%, var(--felt) 32%); }
.center {
  grid-area: center; display: grid; place-items: center; text-align: center; padding: 10px;
  border: 1px dashed rgb(255 255 255 / .25); border-radius: 18px; min-height: 140px;
}
.center .lance-title { font-family: var(--font-serif); font-size: 1.6rem; letter-spacing: .06em; text-transform: uppercase; }
.center .bet-info { font-size: .95rem; opacity: .9; }
.bubble {
  position: absolute; top: -8px; left: 50%; transform: translate(-50%, -100%);
  background: #fffcf5; color: #1d2420; padding: 4px 10px; border-radius: 10px; font-weight: 700; font-size: .85rem;
  box-shadow: var(--shadow); white-space: nowrap; z-index: 3; animation: pop calc(220ms * var(--speed)) ease-out;
}
.bubble.ordago { background: var(--accent); color: var(--accent-fg); }
@keyframes pop { from { transform: translate(-50%, -80%) scale(.7); opacity: 0; } to { transform: translate(-50%, -100%) scale(1); opacity: 1; } }

.hand { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.card {
  width: 84px; height: 126px; border-radius: 8px; background: #fffdf6; border: 1px solid var(--card-line);
  box-shadow: var(--shadow); padding: 0; position: relative; display: block;
  transition: transform calc(150ms * var(--speed)); user-select: none;
}
.card .face { width: 100%; height: 100%; display: block; border-radius: 8px; }
.card.small { width: 44px; height: 66px; }
@media (max-width: 560px) { .card { width: 66px; height: 99px; } .card.small { width: 34px; height: 51px; } }
button.card { cursor: pointer; }
button.card[aria-pressed="true"] { transform: translateY(-14px); outline: 3px solid var(--accent); }
.card .equiv { position: absolute; top: 4px; right: 6px; font-size: .65rem; color: var(--accent); font-weight: 700; background: #fffdf6; border-radius: 3px; padding: 0 2px; }

/* Baraja a la derecha del que reparte y reparto animado */
.deck { position: absolute; display: grid; justify-items: center; gap: 2px; z-index: 2; }
.deck .back { position: relative; width: 24px; height: 34px; margin-top: -30px; box-shadow: 1px 1px 0 rgb(0 0 0 / .25); }
.deck .back:first-child { margin-top: 0; }
.deck small { font-size: .65rem; opacity: .85; white-space: nowrap; }
.deck-bottom { right: 24%; bottom: 14px; } .deck-right { right: 24%; top: 14px; }
.deck-top { left: 24%; top: 14px; } .deck-left { left: 24%; bottom: 14px; }
.back.flying { position: absolute; width: 24px; height: 34px; z-index: 5; transition: transform calc(380ms * var(--speed)) ease-out; }

/* Miradas: el avatar gira la cara hacia donde mira */
.chip.gaze { background: rgb(255 255 255 / .12); }
.chip.gaze.on-me { background: var(--gold); color: #1d2420; border-color: var(--gold); font-weight: 600; }
.avatar { transition: transform calc(300ms * var(--speed)); }
[class*="look-bottom-right"], [class*="look-left-bottom"], [class*="look-top-left"] { transform: rotate(-14deg); }
[class*="look-bottom-left"], [class*="look-right-bottom"], [class*="look-top-right"] { transform: rotate(14deg); }
[class*="look-left-right"], [class*="look-right-left"], [class*="look-bottom-top"], [class*="look-top-bottom"] { transform: scale(1.06); }
[class*="-mesa"] { transform: translateY(3px); }

/* Antes de repartir: resumen de la jugada */

/* Señas */
.signals { max-width: 980px; margin: 0 auto; width: 100%; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.sig-col { display: grid; gap: 8px; align-content: start; }
.sig-col p { margin: 0; }
.seen-list { display: grid; gap: 6px; }
.seen { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); }
.seen.ally { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.seen.foe { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.sig-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); font-weight: 600; }
.moment { padding: 8px 10px; border-radius: 10px; font-weight: 600; }
.moment.good { background: color-mix(in srgb, var(--ok) 18%, transparent); }
.moment.bad { background: color-mix(in srgb, var(--warn) 22%, transparent); }
.moment.off { background: var(--surface-2); }
.sig-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.sig-btn { display: grid; justify-items: center; gap: 2px; padding: 10px 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; }
.sig-btn:hover, .sig-btn:focus-visible { border-color: var(--accent); }
.sig-btn .sig-icon { font-size: 1.8rem; line-height: 1; }
.sig-btn small { color: var(--muted); text-align: center; }
/* Mis cartas y lo que llevo */
.my-cards { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; }
.jugadas { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
@media (max-width: 560px) { .jugadas { flex-direction: row; flex-wrap: wrap; justify-content: center; } }
.jugada { padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: .95rem; border: 2px solid var(--line); background: var(--surface); }
.jugada.on { border-color: var(--ok); color: var(--ok); }
.jugada.gold { border-color: var(--gold); background: var(--gold); color: #1d2420; }
.jugada.off { color: var(--muted); }
.small-btn { font-size: .85rem; padding: 6px 10px; min-height: 40px; }

.actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.act { min-width: 112px; min-height: 48px; border-radius: 12px; font-weight: 700; letter-spacing: .03em; border: 2px solid var(--line); background: var(--surface); }
.act.ordago { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.act.quiero { border-color: var(--ok); }
.act.noquiero { border-color: var(--muted); }
.amount { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.amount button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.amount output { min-width: 2ch; text-align: center; font-weight: 700; }
.status-line { text-align: center; color: var(--muted); min-height: 1.5em; }
.help-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.help-panel ul { margin: 6px 0 0; padding-left: 1.2em; }
.invite { background: var(--surface); border: 1px dashed var(--gold); border-radius: var(--radius); padding: 10px 14px; }

@media (max-width: 640px) {
  .table { grid-template-columns: minmax(64px, .8fr) minmax(0, 2fr) minmax(64px, .8fr); border-width: 6px; padding: 8px; border-radius: 18px; min-height: 300px; }
  .avatar { width: 42px; height: 42px; font-size: 1.3rem; }
  .backs .back { width: 12px; height: 18px; }
  .center .lance-title { font-size: 1.2rem; }
  .card { width: 58px; height: 84px; }
  .act { min-width: 96px; }
  .scorebar { grid-template-columns: 1fr; }
  .score-line { justify-content: flex-start; }
}

/* ------------------------------------------------------------------ replay y modal */
.replay-controls { display: flex; gap: 6px; justify-content: center; }
.replay-controls button { min-width: 48px; min-height: 44px; font-size: 1.1rem; }
.event-log { max-height: 280px; overflow: auto; font-size: .88rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.event-log li { padding: 4px 10px; border-bottom: 1px solid var(--line); list-style: none; }
.event-log li.now { background: var(--surface-2); font-weight: 600; }
.event-log ol { margin: 0; padding: 0; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--fg); max-width: min(720px, 94vw); width: 100%; padding: 20px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(10 14 12 / .55); }
.tutorial-step { display: grid; gap: 12px; }
.example { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 20; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
:root[data-motion="reduce"] * { animation: none !important; transition: none !important; }

/* Pantalla de carga de la versión web (Pyodide) */
.booting {
  position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: .75rem;
  background: var(--bg); color: var(--fg); text-align: center; padding: 16px;
}
.booting p { margin: 0; font-weight: 600; }
.booting small { color: var(--muted); max-width: 32ch; }
.shown-hands { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.shown-hands .hand { justify-content: flex-start; gap: 4px; }

/* Panel de administración */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 2px; }
.tile span { color: var(--muted); font-size: .85rem; }
.tile strong { font-size: 2rem; font-family: var(--font-serif); line-height: 1.1; }
.tile small { color: var(--muted); }
.chart { margin: 8px 0 0; } .chart rect.hit:hover + rect { opacity: .75; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }

.site-footer { text-align: center; padding: 18px 16px 28px; font-size: .85rem; color: var(--muted); }
.site-footer a { color: inherit; }

/* Caras: se pulsan para mirar a ese jugador; hacen el gesto de la seña */
.avatar { overflow: hidden; padding: 0; }
.avatar .face { width: 100%; height: 100%; display: block; }
.face-btn { cursor: pointer; border-width: 3px; }
.face-btn:hover, .face-btn:focus-visible { box-shadow: 0 0 0 3px var(--gold); }
.face-btn.watched { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--gold); }
.seat .avatar { width: 72px; height: 72px; }
.face.gesturing { animation: gesture calc(450ms * var(--speed)) ease-in-out 3; }
@keyframes gesture { 50% { transform: scale(1.12); } }

/* Piedras sobre el tapete: sueltas (1 tanto) y de 5, delante de quien las cuenta */
.pile { display: grid; justify-items: center; gap: 2px; min-height: 22px; }
.pile small { font-size: .65rem; opacity: .85; }
.stones-row { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 140px; min-height: 14px; position: relative; }
.stone { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f3ead7, #9c9486);
  box-shadow: 0 1px 0 rgb(0 0 0 / .45); display: grid; place-items: center; }
.stone.five { width: 20px; height: 20px; background: radial-gradient(circle at 35% 35%, #ffe7a3, #b8862e); color: #3a2a10; font-size: .6rem; font-weight: 800; }
.seat.bottom .pile { --fx: 0px; --fy: -110px; } .seat.top .pile { --fx: 0px; --fy: 110px; }
.seat.left .pile { --fx: 130px; --fy: 0px; } .seat.right .pile { --fx: -130px; --fy: 0px; }
.stone.arrive { animation: stone-in calc(800ms * var(--speed)) ease-out both; }
@keyframes stone-in { from { transform: translate(var(--fx), var(--fy)) scale(.5); opacity: 0; } }
.ghosts { position: absolute; inset: 0; display: flex; gap: 3px; justify-content: center; pointer-events: none; }
.stone.leave { animation: stone-out calc(900ms * var(--speed)) ease-in forwards; }
@keyframes stone-out { from { opacity: 1; } to { transform: translate(var(--fx), var(--fy)) scale(.5); opacity: 0; } }
.signals-choice { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.signals-choice p { margin: 4px 0 0; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label { border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.score-help { margin-bottom: 16px; } .score-help p { margin: 4px 0; }
.stone-demo { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--felt); color: #f3ead7; width: fit-content; }
.pile-demo { display: inline-flex; gap: 3px; align-items: center; } .pile-demo small { margin-left: 4px; }
.now-playing { text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; opacity: .8; }
.login-gate { max-width: 620px; margin: 40px auto; text-align: center; } .login-gate .row { justify-content: center; }

/* Conteo paso a paso en el centro de la mesa */
.review { display: grid; gap: 6px; justify-items: center; max-width: 440px; }
.review p { margin: 0; } .review ul { margin: 0; padding-left: 18px; text-align: left; }
.table.reviewing .center { background: rgb(0 0 0 / .28); border-style: solid; }
.seat.lit .hand.lit .card { outline: 3px solid var(--gold); }
.seat.lit .seat-name { color: var(--gold); }

/* Cambio de jugador en el mismo dispositivo */
.curtain { max-width: 520px; margin: 0 auto; text-align: center; }
.players-choice { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; display: grid; gap: 4px; }
.players-choice legend { font-weight: 600; padding: 0 4px; }
@media (max-width: 560px) { .seat .avatar { width: 56px; height: 56px; } }
.report { display: grid; gap: 12px; max-height: 60vh; overflow: auto; }
.report article { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.report h3 { margin: 0 0 4px; } .report ul { margin: 4px 0; padding-left: 18px; }

/* Mesa en el centro y paneles a los lados (en pantallas anchas) */
.game:has(.game-layout) { max-width: 1560px; }
.game-layout { display: grid; gap: 12px; }
.game-main { display: grid; gap: 12px; min-width: 0; }
.side { display: grid; gap: 12px; align-content: start; }
.side:empty { display: none; }
@media (min-width: 1180px) {
  .game-layout { grid-template-columns: 270px minmax(0, 1fr) 300px; align-items: start; }
  .side { position: sticky; top: 12px; }
  .side .signals { grid-template-columns: 1fr; }
}
@media (max-width: 1179px) { .side-left { order: 2; } .side-right { order: 3; } .game-main { order: 1; } }
.play-panel table th { text-align: left; font-weight: 600; white-space: nowrap; padding-right: 8px; }
.play-panel tr.now { background: color-mix(in srgb, var(--gold) 22%, transparent); }
.play-panel td, .play-panel th { padding: 6px 4px; vertical-align: top; }
.now-line { font-weight: 600; margin: 0 0 6px; }
.chat-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.sig-now { background: var(--gold); color: #1d2420; border-color: var(--gold); font-weight: 700; font-size: .8rem; animation: chip-pop calc(260ms * var(--speed)) ease-out; }
@keyframes chip-pop { from { transform: scale(.6); opacity: 0; } }
.side, .side > * { min-width: 0; }
.play-panel table { width: 100%; table-layout: fixed; }
.play-panel table.data th { width: 34%; white-space: normal; } .play-panel table.data td { white-space: normal; overflow-wrap: anywhere; text-align: left; }

/* ------------------------------------------------------------------ mesa con publicidad */
/* El marcador y la fase van arriba, dentro del tapete: gana espacio a la pantalla. */
.table { grid-template-areas: "score score score" ". top ." "left center right" ". bottom ."; }
.table > .scorebar {
  grid-area: score; position: static; z-index: auto; margin: -4px auto 4px; width: min(100%, 760px);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: center;
  background: rgb(0 0 0 / .28); border: 1px solid rgb(255 255 255 / .18); border-radius: 999px; padding: 4px 16px; color: #f3ead7;
}
.table > .scorebar .score-line { justify-content: flex-start; }
.table > .scorebar .score-line:last-child { justify-content: flex-end; flex-direction: row-reverse; }
.table > .scorebar .score-line strong { font-size: 1.5rem; }
.table > .scorebar .phase-box { display: grid; justify-items: center; gap: 2px; }
.table > .scorebar .phase-box small { font-size: .7rem; opacity: .85; }
.table > .scorebar .lance { color: #f3ead7; border-color: rgb(255 255 255 / .3); padding: 1px 8px; }
.table > .scorebar .lance.current { background: var(--gold); color: #1d2420; border-color: var(--gold); }
/* Cartas de los bots más grandes, con el reverso del patrocinador */
.backs.ad { gap: 0; }
.backs.ad .bcard { width: 46px; height: 69px; filter: drop-shadow(0 2px 3px rgb(0 0 0 / .45)); }
.backs.ad .bcard + .bcard { margin-left: -12px; }
/* Consumición junto a las cartas de cada jugador */
.hand-row { display: flex; align-items: flex-end; justify-content: center; gap: 6px; }
.drinkbox:empty { display: none; }
.drinkbox svg.drink { width: 30px; height: 50px; display: block; filter: drop-shadow(0 3px 3px rgb(0 0 0 / .45)); }
.my-cards .drinkbox svg.drink { width: 40px; height: 66px; }
@media (min-width: 900px) {
  .backs.ad .bcard { width: 60px; height: 90px; }
  .backs.ad .bcard + .bcard { margin-left: -16px; }
  .drinkbox svg.drink { width: 36px; height: 60px; }
}
@media (max-width: 640px) {
  .table { grid-template-areas: "score score score" ". top ." "left center right" ". bottom ." "hand hand hand"; }
  .table > .scorebar { grid-template-columns: 1fr 1fr; border-radius: 14px; padding: 4px 10px; }
  .table > .scorebar .phase-box { grid-column: 1 / -1; grid-row: 1; }
  .table > .scorebar .score-line strong { font-size: 1.2rem; }
  .backs.ad .bcard { width: 30px; height: 45px; }
  .backs.ad .bcard + .bcard { margin-left: -10px; }
  .drinkbox svg.drink { width: 20px; height: 34px; }
}
.deck-top, .deck-right { top: 70px; }
@media (max-width: 640px) {
  .deck-top, .deck-right { top: 96px; }
  .seat.left .hand-row, .seat.right .hand-row { flex-wrap: wrap; max-width: 100%; }
  .seat.left .backs.ad .bcard, .seat.right .backs.ad .bcard { width: 26px; height: 39px; }
  .seat.left .backs.ad .bcard + .bcard, .seat.right .backs.ad .bcard + .bcard { margin-left: -9px; }
}
@media (min-width: 641px) {
  .seat.left .backs.ad .bcard, .seat.right .backs.ad .bcard { width: 48px; height: 72px; }
  .seat.left .backs.ad .bcard + .bcard, .seat.right .backs.ad .bcard + .bcard { margin-left: -26px; }
  .seat.left .hand-row, .seat.right .hand-row { max-width: 100%; }
}

/* ------------------------------------------------------------------ publicidad y campeonatos */
.ad-preview { display: flex; gap: 10px; align-items: flex-end; justify-content: center; padding: 18px; border-radius: 18px;
  background: radial-gradient(ellipse at center, var(--felt-line), var(--felt) 60%, var(--felt-2)); }
.ad-preview .bcard.big { width: 96px; height: 144px; filter: drop-shadow(0 3px 4px rgb(0 0 0 / .45)); }
.ad-preview .drinkbox.big svg.drink { width: 60px; height: 100px; }
.champ-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.champ-card { display: grid; gap: 4px; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.champ-card.inscripcion { box-shadow: inset 4px 0 0 var(--felt); }
.champ-card.en_juego { box-shadow: inset 4px 0 0 var(--gold); }
.chip-light { justify-self: start; font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--gold); color: #1d2420; }
.bracket { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 14px; padding-bottom: 8px; }
.bracket .round { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.bracket .round h3 { margin: 0; text-align: center; font-size: 1rem; color: var(--muted); }
.match { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.match.mine { border: 2px solid var(--gold); }
.match .team-row { display: flex; justify-content: space-between; gap: 6px; padding: 6px 10px; font-size: .9rem; }
.match .team-row + .team-row { border-top: 1px solid var(--line); }
.match .team-row.won { font-weight: 700; background: color-mix(in srgb, var(--felt) 14%, transparent); }
.match .team-row.lost { color: var(--muted); text-decoration: line-through; }
.match .team-row.me span { color: var(--accent); font-weight: 700; }
.match .team-row.tbd { color: var(--muted); font-style: italic; }
.match > .btn, .match > small { display: block; margin: 6px 10px 8px; }
.match .adm-win { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 4px 10px 8px; }
.champion { font-size: 1.2rem; text-align: center; background: color-mix(in srgb, var(--gold) 25%, var(--surface)); }
ul.teams { padding-left: 18px; } ul.teams li { margin: 6px 0; }
#ads-form input[type="color"] { width: 64px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
section.panel.stack[aria-label="Campeonatos"], section.panel.stack[aria-label="Publicidad"] { align-content: start; align-self: start; }
/* Con «Campeonatos» el menú no cabe en una fila del móvil: se desplaza dentro de su franja */
@media (max-width: 760px) {
  .topnav { overflow-x: auto; justify-content: flex-start; flex-wrap: nowrap; scrollbar-width: none; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav button { flex: none; }
}

/* Mis cartas y mis botones, dentro de la mesa como las de los demás */
.table, .table:has(> .scorebar) { grid-template-areas: "score score score" ". top ." "left center right" ". bottom ." "hand hand hand"; }
.table-hand { grid-area: hand; display: grid; gap: 8px; justify-items: center; padding-top: 4px; }
.table-hand .status-line { color: #f3ead7; opacity: .85; }
.table-hand .jugadas .jugada { border-color: rgb(255 255 255 / .35); }

/* Jugando, el menú de arriba se esconde y aparece al pasar el ratón por el borde superior */
.nav-hot { display: none; }
body.playing .nav-hot { display: flex; justify-content: center; position: fixed; top: 0; left: 0; right: 0; height: 14px; z-index: 6; }
body.playing .nav-hot span { font-size: .7rem; background: var(--surface); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; padding: 0 10px; height: 16px; line-height: 16px; color: var(--muted); }
body.playing .topbar { position: fixed; left: 0; right: 0; top: 0; transform: translateY(-100%); transition: transform 200ms ease; z-index: 7; box-shadow: var(--shadow); }
body.playing .nav-hot:hover + .topbar, body.playing .topbar:hover, body.playing .topbar:focus-within { transform: none; }
body.playing #main { padding-top: 14px; }
@media (hover: none) { body.playing .nav-hot { height: 22px; } body.playing .nav-hot:active + .topbar { transform: none; } }
.play-form { margin-bottom: 16px; }
.seg-field { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.seg-field legend { font-weight: 600; margin-bottom: 6px; }
.more summary { cursor: pointer; color: var(--muted); }
.more .form-grid { margin-top: 10px; }
.btn.big { font-size: 1.1rem; padding: 12px 24px; justify-self: start; }
.game-row { justify-content: space-between; border-bottom: 1px solid var(--line); padding: 6px 0; color: inherit; }

/* ------------------------------------------------------------------ todo en una pantalla al jugar */
/* Jugando, la mesa (rectangular) y los paneles laterales, pegados a los bordes, ocupan la pantalla
   entera: se ve todo, botones incluidos, sin desplazarse. */
body.playing .site-footer { display: none; }
body.playing #main { padding-top: 0; }
body.playing .game {
  max-width: none; height: 100dvh; padding: 16px 0 6px; gap: 4px; box-sizing: border-box; overflow: hidden;
  grid-template-rows: minmax(0, 1fr) auto;
}
body.playing .game-layout { height: 100%; min-height: 0; gap: 8px; }
body.playing .game-main { height: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr); }
body.playing .side { height: 100%; overflow-y: auto; position: static; align-content: start; }
body.playing .side .panel { border-radius: 0; padding: 10px 12px; }
body.playing .side-left .panel { border-left: 0; }
body.playing .side-right .panel { border-right: 0; }
body.playing .side .card-title { font-size: 1.05rem; margin: 0 0 4px; }
body.playing .game-tools { justify-content: center; gap: 6px; }
body.playing .game-tools .btn { padding: 4px 10px; font-size: .85rem; }
body.playing .help-panel:not([hidden]) { position: fixed; right: 16px; bottom: 50px; width: min(460px, 90vw); max-height: 60vh; overflow: auto; z-index: 8; box-shadow: var(--shadow); }
/* Mesa rectangular que llena su hueco */
body.playing .table {
  height: 100%; min-height: 0; box-sizing: border-box; padding: 8px 12px; gap: 2px; border-radius: 6px; border-width: 8px;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto; overflow: hidden;
}
body.playing .center { min-height: 0; padding: 4px; }
body.playing .center .lance-title { font-size: clamp(1rem, 3vh, 1.6rem); }
body.playing .seat { gap: 2px; }
body.playing .seat .avatar { width: clamp(36px, 6vh, 56px); height: clamp(36px, 6vh, 56px); }
body.playing .seat-name { font-size: .8rem; }
body.playing .pile small { display: none; }
body.playing .stone { width: 11px; height: 11px; } body.playing .stone.five { width: 16px; height: 16px; font-size: .5rem; }
body.playing .backs.ad .bcard,
body.playing .seat.left .backs.ad .bcard, body.playing .seat.right .backs.ad .bcard { height: clamp(30px, 7vh, 72px); width: calc(clamp(30px, 7vh, 72px) * 2 / 3); }
body.playing .drinkbox svg.drink { height: clamp(24px, 5vh, 60px); width: auto; }
body.playing .table-hand { gap: 4px; padding-top: 0; }
body.playing .my-cards { gap: 10px; }
body.playing .my-cards .card { height: clamp(66px, 14vh, 126px); width: calc(clamp(66px, 14vh, 126px) * 2 / 3); }
body.playing .my-cards .drinkbox svg.drink { height: clamp(30px, 7vh, 66px); }
body.playing .jugada { padding: 2px 10px; font-size: .85rem; }
body.playing .act { min-height: 40px; padding: 6px 14px; }
body.playing .status-line { min-height: 1.2em; font-size: .85rem; }
body.playing .table > .scorebar { margin: 0 auto 2px; padding: 2px 14px; }
body.playing .table > .scorebar .score-line strong { font-size: 1.2rem; }
body.playing .deck-top, body.playing .deck-right { top: 52px; }
body.playing .curtain { position: fixed; inset: 30% auto auto 50%; transform: translateX(-50%); z-index: 8; }
@media (max-width: 1179px) {
  body.playing .game { height: auto; overflow: visible; padding: 16px 6px 6px; }
  body.playing .game-main { height: auto; }
  body.playing .table { height: calc(100dvh - 24px); }
}
@media (min-width: 1180px) {
  body.playing { overflow: hidden; }
  body.playing .side .panel:last-child { min-height: 100%; box-sizing: border-box; }
}
/* La baraja de quien reparte desde mi sitio va a la altura de mi cara, no encima de mis cartas */
body.playing .deck-bottom { bottom: auto; top: 54%; right: 22%; }
/* Los botones de acción dentro del tapete conservan su texto oscuro (el tapete pone el texto claro) */
.table .act, .table .amount { color: var(--fg); }
.table .act.ordago { color: var(--accent-fg); }

/* ------------------------------------------------------------------ mis cartas centradas */
/* Mis cuatro cartas, siempre en una fila y en el centro de la mesa; la consumición y lo que llevo
   («Par de…», «Sin juego…») van a un lado sin descentrarlas (en el móvil, debajo). */
.my-cards { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; width: 100%; }
.my-cards > .hand { grid-column: 2; flex-wrap: nowrap; }
.my-cards > .my-extras { grid-column: 3; justify-self: start; display: flex; align-items: center; gap: 10px; min-width: 0; }
@media (max-width: 760px) {
  .my-cards { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .my-cards > .hand, .my-cards > .my-extras { grid-column: 1; justify-self: center; }
  .my-cards > .hand { gap: 6px; }
  body.playing .my-cards .card { width: min(21vw, 84px); height: calc(min(21vw, 84px) * 1.5); }
  .my-cards .jugadas { flex-direction: row; flex-wrap: wrap; justify-content: center; }
}

/* ------------------------------------------------------------------ nada tapa los botones */
/* En pantallas estrechas no cabe todo en una pantalla: la mesa crece lo que haga falta en vez de
   montar unos asientos encima de otros. Y el conteo de la jugada queda siempre por encima, para
   que «Siguiente» y «Repartir» se puedan pulsar. */
.table.reviewing .center { position: relative; z-index: 4; background: color-mix(in srgb, var(--felt) 92%, black); }
@media (max-width: 760px) {
  body.playing .table { height: auto; min-height: calc(100dvh - 24px); overflow: visible; grid-template-rows: none; }
  body.playing .center { min-height: 120px; }
  body.playing .seat.left .backs.ad .bcard, body.playing .seat.right .backs.ad .bcard { width: 26px; height: 39px; }
  body.playing .seat.left .backs.ad .bcard + .bcard, body.playing .seat.right .backs.ad .bcard + .bcard { margin-left: -12px; }
  body.playing .seat.left .hand-row, body.playing .seat.right .hand-row { flex-wrap: wrap; }
}

/* Resultado al guardar la publicidad: se queda escrito bajo el botón. */
.ok-msg { color: #2e7d32; font-weight: 600; }
.error-msg { color: #c62828; font-weight: 600; }

/* ------------------------------------------------------------------ salas online */
.room { max-width: 640px; margin-inline: auto; }
.room-code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: clamp(2.4rem, 11vw, 3.6rem); font-weight: 800;
  letter-spacing: .25em; text-align: center; margin: 4px 0; padding: 10px 0 10px .25em; border: 3px dashed var(--gold); border-radius: 14px; background: color-mix(in srgb, var(--gold) 10%, transparent); }
.room-link { flex: 1 1 220px; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, currentColor 25%, transparent); font: inherit; background: transparent; color: inherit; }
.room-seats { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.room-seats li { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
.room-seats li.taken { border-color: var(--gold); }
.room-seats li.free strong { opacity: .6; font-weight: 500; }
.join-room { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent); }
.join-room .field { flex: 1 1 200px; }
.join-room input { text-transform: uppercase; letter-spacing: .15em; }

/* ------------------------------------------------------------------ bots más grandes */
/* Caras y cartas de los otros tres jugadores, un poco mayores (también en el móvil). */
body.playing .seat .avatar { width: clamp(46px, 8vh, 78px); height: clamp(46px, 8vh, 78px); }
body.playing .backs.ad .bcard,
body.playing .seat.left .backs.ad .bcard, body.playing .seat.right .backs.ad .bcard { height: clamp(40px, 9vh, 92px); width: calc(clamp(40px, 9vh, 92px) * 2 / 3); }
@media (max-width: 760px) {
  body.playing .seat .avatar { width: 62px; height: 62px; }
  body.playing .seat.top .backs.ad .bcard { width: 40px; height: 60px; }
  body.playing .seat.left .backs.ad .bcard, body.playing .seat.right .backs.ad .bcard { width: 34px; height: 51px; }
  body.playing .seat.left .backs.ad .bcard + .bcard, body.playing .seat.right .backs.ad .bcard + .bcard { margin-left: -16px; }
}

/* ------------------------------------------------------------------ bocadillos sin tapar caras */
/* El bocadillo («Paso», «Envido»…) se coloca respecto a la cara, no al asiento: en la mesa a
   pantalla completa el asiento puede ser más bajo que su contenido y el bocadillo acababa
   encima de la cara. En los bots de los lados y el de enfrente va al lado, hacia el centro. */
.avatar-wrap { position: relative; display: grid; place-items: center; }
.avatar-wrap > .bubble { animation-name: pop-in; }
.seat.left .avatar-wrap > .bubble, .seat.top .avatar-wrap > .bubble { top: 50%; left: calc(100% + 10px); transform: translateY(-50%); }
.seat.right .avatar-wrap > .bubble { top: 50%; left: auto; right: calc(100% + 10px); transform: translateY(-50%); }
.seat.bottom .avatar-wrap > .bubble { top: -8px; }
@keyframes pop-in { from { scale: .7; opacity: 0; } to { scale: 1; opacity: 1; } }
@media (max-width: 760px) {
  /* En el móvil la mesa crece hacia abajo y hay sitio encima de cada cara. */
  .seat.left .avatar-wrap > .bubble, .seat.right .avatar-wrap > .bubble { top: -10px; transform: translateY(-100%); }
  .seat.left .avatar-wrap > .bubble { left: 0; right: auto; }
  .seat.right .avatar-wrap > .bubble { left: auto; right: 0; }
}
/* En pantallas bajas (p. ej. 1280×720) mi cara podía quedar encima de «¿Repartimos? Sí»: los
   botones del centro siempre por encima. */
body.playing .center { position: relative; z-index: 4; }
