/* Mesa de Truco. Paño verde, naipes de tinta plena y un anotador de papel cuadriculado. */

@font-face { font-family: Archivo; src: url(/fuentes/archivo-400-900.woff2) format('woff2'); font-weight: 400 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: Kalam; src: url(/fuentes/kalam-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Kalam; src: url(/fuentes/kalam-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --pano: #0f4a39;
  --pano-oscuro: #0a3327;
  --pano-luz: #186249;
  --papel: #fbfaf2;
  --renglon: rgba(41, 98, 190, 0.17);
  --birome: #1b3f8f;
  --rojo: #c0321f;
  --oro: #f4be1a;
  --tinta: #1f1d19;
  --crema: #f1ecd9;
  --nos: #8fb4e8;
  --ellos: #f29480;
  --letra: Archivo, system-ui, sans-serif;
  --mano: Kalam, 'Comic Sans MS', cursive;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--letra);
  font-size: 16px;
  line-height: 1.45;
  color: var(--crema);
  background: radial-gradient(120% 90% at 50% 30%, var(--pano-luz), var(--pano) 55%, var(--pano-oscuro));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--oro); outline-offset: 2px; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; }
[hidden] { display: none !important; }
svg.naipe { display: block; width: 100%; height: auto; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.28)); }

#app { min-height: 100%; }

/* ---------- Papel cuadriculado ---------- */
.papel, .maestro, .hoja, .resumen .r-hoja, .ficha {
  color: var(--tinta);
  background-color: var(--papel);
  background-image: linear-gradient(var(--renglon) 1px, transparent 1px), linear-gradient(90deg, var(--renglon) 1px, transparent 1px);
  background-size: 18px 18px;
  background-position: -1px -1px;
}

/* ---------- Botones ---------- */
.boton {
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--papel);
  color: var(--tinta);
  font-weight: 700;
  font-stretch: 88%;
  font-size: 1rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.08s, box-shadow 0.08s;
}
.boton:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.boton:disabled { opacity: 0.55; box-shadow: none; }
.boton.principal { background: var(--oro); }
.boton.ancho { width: 100%; }
.boton.chico { min-height: 38px; font-size: 0.875rem; padding: 0 12px; font-weight: 600; }
.boton.no { background: #f6d9d2; }
.boton.sugerido { background: var(--oro); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 0 3px var(--papel), 0 0 0 6px var(--rojo); }
.boton.tenue { background: none; box-shadow: none; color: var(--crema); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; min-height: 40px; }

.segmento { display: inline-flex; border-radius: 10px; background: rgba(0, 0, 0, 0.25); padding: 3px; gap: 3px; }
.segmento button { border: 0; background: none; color: var(--crema); min-height: 40px; padding: 0 14px; border-radius: 8px; font-weight: 600; }
.segmento button[aria-pressed='true'] { background: var(--papel); color: var(--tinta); }

/* ---------- Inicio ---------- */
.inicio { max-width: 520px; margin: 0 auto; padding: 28px 20px 40px; min-height: 100dvh; display: flex; flex-direction: column; }
.portada { text-align: left; }
.abanico { height: 190px; position: relative; margin: 6px 0 22px; }
.abanico > div { position: absolute; left: 50%; bottom: 0; width: 112px; margin-left: -56px; transform-origin: 50% 100%; animation: repartir 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.abanico > div:nth-child(1) { transform: translateX(-62px) rotate(-13deg); animation-delay: 0.05s; }
.abanico > div:nth-child(2) { transform: translateY(-10px); animation-delay: 0.2s; z-index: 1; }
.abanico > div:nth-child(3) { transform: translateX(62px) rotate(13deg); animation-delay: 0.35s; }
@keyframes repartir { from { transform: translateY(-120vh) rotate(40deg); opacity: 0; } }
.portada h1 { font-size: clamp(2.6rem, 13vw, 3.7rem); line-height: 0.92; font-weight: 900; font-stretch: 68%; letter-spacing: -0.01em; text-transform: uppercase; color: var(--papel); }
.portada p { margin-top: 12px; font-size: 1.125rem; max-width: 30ch; color: var(--crema); }
.entradas { margin-top: 28px; display: grid; gap: 10px; }
.entrada { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 12px; text-decoration: none; padding: 14px 16px 14px 14px; border-radius: 12px; background: var(--papel); color: var(--tinta); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); }
.entrada svg { width: 38px; height: 38px; }
.entrada b { display: block; font-size: 1.2rem; font-stretch: 85%; font-weight: 800; }
.entrada span { display: block; font-size: 0.95rem; color: #55514a; }
.entrada:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.pie { margin-top: auto; padding-top: 28px; font-size: 0.9rem; color: var(--crema); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.pie button { background: none; border: 0; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Pantallas de preparación y texto ---------- */
.pantalla { max-width: 560px; margin: 0 auto; padding: 14px 20px 48px; min-height: 100dvh; }
.volver { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin-left: -6px; padding: 0 8px 0 2px; border: 0; background: none; color: var(--crema); font-weight: 600; text-decoration: none; }
.pantalla h1 { font-size: 2.1rem; line-height: 1; font-weight: 900; font-stretch: 70%; text-transform: uppercase; color: var(--papel); margin: 10px 0 8px; }
.pantalla .bajada { color: var(--crema); margin-bottom: 22px; max-width: 46ch; }
.campo { margin: 0 0 20px; border: 0; padding: 0; min-width: 0; }
.campo > legend, .campo > label, .etiqueta { display: block; padding: 0; font-weight: 700; margin-bottom: 8px; color: var(--papel); }
.campo small { display: block; margin-top: 6px; color: var(--crema); opacity: 0.85; font-size: 0.875rem; }
.entrada-texto { width: 100%; min-height: 46px; border-radius: 10px; border: 2px solid transparent; background: var(--papel); color: var(--tinta); padding: 0 12px; }
.entrada-texto:focus-visible { outline: none; border-color: var(--oro); }
.fila-nombre { display: grid; grid-template-columns: 1fr; gap: 4px; margin-bottom: 10px; }
.fila-nombre span { font-size: 0.875rem; color: var(--crema); }
.error { background: #f6d9d2; color: #6b1608; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-weight: 600; }
.paso { display: grid; grid-template-columns: 1fr 44px 40px 44px; align-items: center; gap: 6px; margin-bottom: 8px; }
.paso button { height: 44px; border: 0; border-radius: 10px; background: var(--papel); color: var(--tinta); font-size: 1.4rem; font-weight: 700; }
.paso b { text-align: center; font-size: 1.3rem; font-variant-numeric: tabular-nums; }

.en-linea { display: flex; gap: 8px; }
.en-linea .entrada-texto { flex: 1; min-width: 0; }
textarea.entrada-texto { padding: 10px 12px; resize: vertical; line-height: 1.4; }
.aviso-ok { background: #d9ecd6; color: #17401d; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-weight: 600; }
.boton.google { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; background: #fff; }
.como-boton { display: grid; place-items: center; text-decoration: none; }
.separador { text-align: center; margin: 16px 0 14px; font-size: 0.9rem; opacity: 0.85; }
.enlaces { display: flex; flex-wrap: wrap; gap: 0 18px; margin-top: 10px; }
.letra-chica { font-size: 0.85rem; margin-top: 10px; opacity: 0.9; }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--papel); }
.avatar.sin-foto { display: inline-grid; place-items: center; color: var(--birome); font-family: var(--mano); font-weight: 700; font-size: 1.15rem; line-height: 1; }
.avatar.grande { width: 84px; height: 84px; font-size: 2.6rem; }
.perfil { display: flex; gap: 16px; align-items: center; margin: 6px 0 24px; }
.perfil-nombre { font-size: 1.5rem; font-weight: 800; font-stretch: 80%; color: var(--papel); line-height: 1.1; }
.perfil .subir { display: inline-grid; place-items: center; margin-top: 8px; cursor: pointer; }
.perfil .subir:focus-within { outline: 3px solid var(--oro); outline-offset: 2px; }
.peligro { margin-top: 28px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.2); }
.peligro summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--ellos); font-weight: 600; }
.peligro p, .peligro label { display: block; margin: 8px 0; font-size: 0.95rem; }
.pie a { text-underline-offset: 3px; }
.pie-cuenta { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; line-height: 1.2; flex-basis: 100%; }
.ch-foto { flex: none; width: 18px; height: 18px; border-radius: 50%; object-fit: cover; margin-left: -3px; }

/* Anotador suelto */
.hoja-anotador { position: relative; max-width: 360px; margin: 0 auto 16px; border-radius: 10px; padding: 8px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); color: var(--tinta); background-color: var(--papel); background-image: linear-gradient(var(--renglon) 1px, transparent 1px), linear-gradient(90deg, var(--renglon) 1px, transparent 1px); background-size: 18px 18px; }
.hoja-anotador .lado { position: absolute; top: 0; bottom: 0; width: 50%; border: 0; background: transparent; z-index: 1; border-radius: 10px; }
.hoja-anotador .lado[data-lado='0'] { left: 0; }
.hoja-anotador .lado[data-lado='1'] { right: 0; }
.hoja-anotador .lado:active { background: rgba(27, 63, 143, 0.08); }
.pasos-anotador { max-width: 360px; margin: 0 auto 18px; }
.subtitulo { font-size: 1.3rem; font-weight: 800; font-stretch: 80%; color: var(--papel); margin: 26px 0 12px; }

/* Aprender */
.leccion { margin-top: 30px; }
.leccion h2 { font-size: 1.5rem; font-weight: 800; font-stretch: 78%; color: var(--papel); margin-bottom: 8px; }
.leccion p { max-width: 62ch; margin-bottom: 10px; }
.ficha { border-radius: 12px; padding: 14px 16px; margin: 12px 0; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
.ficha p { font-family: var(--mano); font-size: 1.1rem; line-height: 1.35; margin: 0; }
.escalera { display: grid; gap: 6px; }
.escalon { display: grid; grid-template-columns: 26px 1fr; align-items: center; gap: 10px; }
.escalon > b { font-family: var(--mano); font-size: 1.2rem; color: var(--oro); text-align: right; }
.escalon > div { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.escalon .naipe { width: 38px; }
.escalon span { font-size: 0.9rem; margin-left: 4px; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.18); vertical-align: top; }
.tabla th { font-weight: 700; color: var(--papel); }
.ejemplo { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.ejemplo .naipe { width: 46px; }
.ejemplo b { font-family: var(--mano); font-size: 1.25rem; color: var(--oro); }

/* Sala de espera online */
.codigo { font-family: var(--mano); font-weight: 700; font-size: 2.6rem; letter-spacing: 0.12em; color: var(--oro); line-height: 1; }
.lugares { display: grid; gap: 8px; margin: 14px 0 20px; }
.lugar { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px 6px 14px; border-radius: 10px; background: rgba(0, 0, 0, 0.22); }
.lugar::before { content: ''; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--nos); }
.lugar.ellos::before { background: var(--ellos); }
.lugar .l-nombre { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lugar .l-nota { font-size: 0.85rem; opacity: 0.85; }
.lugar.vacio .l-nombre { font-weight: 400; opacity: 0.8; }
.lista-salas { display: grid; gap: 8px; }
.lista-salas .lugar::before { background: var(--oro); }

/* ---------- Juego ---------- */
.juego { position: relative; height: 100dvh; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; overflow: hidden; }
.barra { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px; min-height: 52px; }
.b-icono { width: 40px; height: 40px; border: 0; border-radius: 10px; background: rgba(0, 0, 0, 0.25); color: var(--crema); display: grid; place-items: center; }
.b-texto { border: 0; background: rgba(0, 0, 0, 0.25); color: var(--crema); min-height: 40px; padding: 0 12px; border-radius: 10px; font-weight: 600; font-size: 0.9rem; }
.b-texto:disabled { opacity: 0.4; }
.tanteo { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: rgba(0, 0, 0, 0.25); border-radius: 10px; min-height: 40px; padding: 0 10px; color: var(--crema); font-size: 0.85rem; }
.b-icono:disabled { opacity: 0.4; }
.t-eq { display: inline-flex; align-items: baseline; gap: 5px; min-width: 0; white-space: nowrap; }
.t-eq span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.t-eq b { flex: none; font-family: var(--mano); font-size: 1.45rem; line-height: 1; padding-right: 2px; }
.t-eq.nos b { color: var(--nos); }
.t-eq.ellos b { color: var(--ellos); }
.t-meta { margin-left: auto; opacity: 0.75; font-size: 0.8rem; white-space: nowrap; }
@media (max-width: 420px) { .t-meta { display: none; } }
.conmutador { display: inline-flex; align-items: center; gap: 7px; border: 0; background: rgba(0, 0, 0, 0.25); color: var(--crema); min-height: 40px; padding: 0 12px 0 8px; border-radius: 10px; font-weight: 600; font-size: 0.9rem; }
.conmutador span { width: 30px; height: 18px; border-radius: 9px; background: rgba(255, 255, 255, 0.25); position: relative; transition: background 0.15s; }
.conmutador span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--papel); transition: transform 0.15s; }
.conmutador[aria-pressed='true'] span { background: var(--oro); }
.conmutador[aria-pressed='true'] span::after { transform: translateX(12px); }

.mesa-caja { flex: 1 1 0; min-height: 190px; container-type: size; }
.mesa { height: 100%; display: grid; gap: 2px 6px; padding: 2px 10px 6px; align-items: center; justify-items: center; }
.mesa[data-n='2'] { grid-template: 'arriba' auto 'centro' 1fr 'abajo' auto / 1fr; --tw: min(86px, calc((100cqh - 120px) / 3.08)); }
.mesa[data-n='4'] { grid-template: 'izq arriba der' auto 'centro centro centro' 1fr '. abajo .' auto / minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); --tw: min(56px, calc((100cqh - 110px) / 3.08)); }
.mesa[data-n='6'] { grid-template: 'izq-arriba arriba der-arriba' auto 'centro centro centro' 1fr 'izq-abajo abajo der-abajo' auto / minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); --tw: min(52px, calc((100cqh - 110px) / 3.08)); }
/* Con lugar de sobra, de a cuatro se sientan en cruz como en una mesa de verdad. */
@container (min-height: 340px) {
  .mesa[data-n='4'] { grid-template: '. arriba .' auto 'izq centro der' 1fr '. abajo .' auto / minmax(0, 1fr) auto minmax(0, 1fr); --tw: min(64px, calc((100cqh - 110px) / 4.62)); }
}
.puesto { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; transition: opacity 0.2s; }
.puesto[data-pos='arriba'] { grid-area: arriba; }
.puesto[data-pos='abajo'] { grid-area: abajo; flex-direction: column-reverse; }
.puesto[data-pos='izq'] { grid-area: izq; }
.puesto[data-pos='der'] { grid-area: der; }
.puesto[data-pos='izq-arriba'] { grid-area: izq-arriba; }
.puesto[data-pos='izq-abajo'] { grid-area: izq-abajo; }
.puesto[data-pos='der-arriba'] { grid-area: der-arriba; }
.puesto[data-pos='der-abajo'] { grid-area: der-abajo; }
.puesto.afuera { opacity: 0.4; }
.chapa { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 8px; border-radius: 6px; background: var(--papel); color: var(--tinta); font-size: 0.8rem; font-weight: 700; line-height: 1.3; white-space: nowrap; }
/* El punto dice de qué equipo es: azul los nuestros, rojo los de ellos. */
.chapa::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--birome); }
.puesto.ellos .chapa::before { background: var(--rojo); }
.puesto.turno .chapa { box-shadow: 0 0 0 3px var(--oro); animation: latir 1.3s ease-in-out infinite; }
@keyframes latir { 50% { box-shadow: 0 0 0 5px rgba(244, 190, 26, 0.45); } }
.ch-nombre { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ch-mano, .ch-resto { flex: none; }
.ch-mano { font-family: var(--mano); font-weight: 400; color: var(--rojo); font-size: 0.85rem; }
.ch-resto { display: inline-flex; gap: 2px; }
.ch-resto i { width: 7px; height: 11px; border-radius: 2px; background: var(--birome); }
.tiradas { display: flex; min-height: calc(var(--tw) * 1.54); padding-left: 0; }
.tirada { width: var(--tw); flex: none; }
.tirada + .tirada { margin-left: calc(var(--tw) * -0.52); }
.tirada.vieja { filter: brightness(0.72); }
.tirada.gano svg.naipe { filter: drop-shadow(0 0 0 var(--oro)) drop-shadow(0 0 5px var(--oro)); }
.tirada.entra { animation: tirar 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes tirar { from { transform: translateY(22px) scale(1.25) rotate(-6deg); opacity: 0; } }
.reveladas { display: flex; gap: 2px; }
.reveladas .naipe { width: calc(var(--tw) * 0.6); }
.centro { grid-area: centro; text-align: center; padding: 2px 4px; min-width: 0; }
.bazas { display: inline-flex; gap: 7px; margin-bottom: 2px; }
.bazas i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.45); }
.bazas i.nos { background: var(--nos); border-color: var(--nos); }
.bazas i.ellos { background: var(--ellos); border-color: var(--ellos); }
.bazas i.parda { background: rgba(255, 255, 255, 0.45); border-style: dashed; }
.estado { font-size: 0.82rem; line-height: 1.25; color: var(--crema); }

.panel { flex: none; max-height: 66dvh; overflow-y: auto; padding: 0 10px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.cargando { text-align: center; padding: 30px 0; }

.maestro { border-radius: 12px; padding: 10px 14px 10px 26px; position: relative; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); min-height: 74px; }
.maestro::before { content: ''; position: absolute; left: 16px; top: 0; bottom: 0; width: 1.5px; background: rgba(192, 50, 31, 0.5); }
.m-titulo { font-family: var(--mano); font-weight: 700; font-size: 1.5rem; line-height: 1.15; color: var(--birome); }
.m-decir { font-family: var(--mano); font-size: 1.1rem; color: var(--rojo); margin-top: 2px; }
.m-motivo { margin-top: 4px; font-size: 0.95rem; line-height: 1.4; }
.m-datos { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 0.82rem; font-weight: 600; color: #4a4741; }
.m-mas { margin-top: 6px; font-size: 0.9rem; }
.m-mas summary { cursor: pointer; font-weight: 700; color: var(--birome); min-height: 30px; display: inline-flex; align-items: center; }
.m-mas p { margin-top: 4px; }

.mis-cartas { display: flex; justify-content: center; gap: 8px; padding-top: 14px; touch-action: none; }
.mi-carta { --dx: 0px; --dy: 0px; --sube: 0px; --giro: 0deg; --alto: 0px; width: min(27vw, 104px); padding: 0; border: 0; background: none; border-radius: 10px; position: relative; transform: translate(var(--dx), calc(var(--dy) + var(--alto) + var(--sube))) rotate(var(--giro)); transform-origin: 50% 100%; transition: transform 0.14s ease-out; touch-action: none; user-select: none; -webkit-user-select: none; }
.mi-carta svg { pointer-events: none; }
button.mi-carta:hover { --sube: -6px; }
.mi-carta.elegida { --sube: -14px; }
.mi-carta.sugerida { --sube: -12px; }
.mi-carta.sugerida::after { content: ''; position: absolute; inset: -5px; border: 3px solid var(--oro); border-radius: 14px 11px 15px 10px; pointer-events: none; }
.mi-carta.arrastrando { transition: none; z-index: 3; cursor: grabbing; }
.mi-carta.quieta { filter: brightness(0.9) saturate(0.85); }
/* En abanico: una encima de la otra, como en la mano. */
.mis-cartas.abanico { gap: 0; padding-top: 22px; }
.mis-cartas.abanico .mi-carta + .mi-carta { margin-left: calc(min(27vw, 104px) * -0.42); }
.mis-cartas.abanico .mi-carta.elegida, .mis-cartas.abanico .mi-carta.arrastrando { z-index: 2; }
.ayuda-cartas { text-align: center; font-size: 0.8rem; opacity: 0.8; margin-top: -2px; }
.mis-cartas.chicas { justify-content: flex-start; align-items: center; gap: 4px; padding-top: 0; touch-action: auto; }
.mis-cartas.chicas::before { content: 'Tus cartas'; font-size: 0.8rem; margin-right: 6px; opacity: 0.85; }
.juego .mis-cartas.chicas .mi-carta { width: 34px; opacity: 1; }

.botones { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.botones .boton { flex: 1 1 auto; }
.botones .boton.tenue, .botones .boton.chico { flex: 0 1 auto; }
.botones.otros { justify-content: flex-start; }
.boton.pedir { align-self: center; }

.ajeno { display: flex; flex-direction: column; gap: 8px; }
.aj-titulo { font-size: 1.05rem; font-weight: 600; color: var(--papel); }
.grilla { display: grid; gap: 5px; }
.grilla-palo { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.celda { min-width: 0; height: 36px; padding: 0; border: 0; border-radius: 7px; background: var(--papel); color: var(--tinta); display: flex; align-items: center; justify-content: center; gap: 5px; line-height: 1; }
.celda b { font-size: 1.1rem; font-stretch: 80%; font-weight: 800; }
.celda svg { width: 18px; height: 18px; }
@media (min-width: 480px) {
  .grilla-palo { grid-template-columns: repeat(10, 1fr); }
  .celda { height: 46px; flex-direction: column; gap: 0; }
}
.celda:disabled { opacity: 0.22; }
.celda.elegida { background: var(--oro); box-shadow: 0 0 0 2px var(--papel) inset; }
.celda:active:not(:disabled) { transform: scale(0.94); }

.carga { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.c-titulo { font-size: 1.3rem; font-weight: 800; font-stretch: 80%; color: var(--papel); }
.c-texto { font-size: 0.95rem; }
.escanear { display: grid; place-items: center; cursor: pointer; }
.escanear.ocupado { opacity: 0.75; cursor: progress; }
.escanear:focus-within { outline: 3px solid var(--oro); outline-offset: 2px; }
.carga .error, .carga .aviso-ok { margin-bottom: 0; }
.c-elegidas { display: flex; gap: 8px; justify-content: center; }
.c-hueco { width: 68px; aspect-ratio: 100 / 154; border-radius: 8px; border: 2px dashed rgba(255, 255, 255, 0.4); padding: 0; background: none; }
.c-hueco.lleno { border: 0; }
.c-opciones { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 0.92rem; }
.c-opciones select { min-height: 40px; border-radius: 8px; border: 0; background: var(--papel); color: var(--tinta); padding: 0 8px; margin-left: 6px; }

.resumen { display: grid; grid-template-columns: 1fr 132px; gap: 12px; align-items: start; padding-top: 4px; }
.r-titulo { font-size: 1.5rem; line-height: 1.1; font-weight: 800; font-stretch: 78%; color: var(--papel); margin-bottom: 6px; }
.r-texto ul { font-size: 0.95rem; margin-bottom: 14px; }
.r-texto li { padding: 2px 0; }
.r-texto .boton + .boton { margin-top: 8px; }
.r-espera { font-size: 0.9rem; opacity: 0.9; }
.r-hoja { border-radius: 8px; padding: 4px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); transform: rotate(1.2deg); }

.anotador { display: block; width: 100%; height: auto; }
.an-raya { stroke: var(--birome); stroke-width: 1.6; fill: none; stroke-linecap: round; }
.an-mitad { stroke-dasharray: 5 4; }
.an-palitos { stroke: var(--birome); stroke-width: 2.6; fill: none; stroke-linecap: round; }
.an-nombre { font-family: var(--mano); font-weight: 700; font-size: 17px; fill: var(--birome); }
.an-gana { fill: var(--rojo); }
.an-total { font-family: var(--mano); font-weight: 700; font-size: 20px; fill: var(--tinta); }
.an-chico { font-family: var(--mano); font-size: 9px; fill: #6c6a63; }

.capa { position: absolute; inset: 0; background: rgba(4, 22, 16, 0.72); display: grid; place-items: center; padding: 20px; z-index: 5; }
.hoja { width: min(100%, 320px); max-height: 100%; overflow: auto; border-radius: 10px; padding: 14px 16px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.hoja .boton { margin-top: 12px; background: var(--birome); color: #fff; box-shadow: none; }
.hoja-titulo { font-family: var(--mano); font-weight: 700; font-size: 1.4rem; color: var(--birome); line-height: 1.2; }
.hoja .boton + .boton { margin-top: 8px; }
.otra-partida { justify-self: start; margin: -4px 0 4px; min-height: 36px; padding: 0 4px; border: 0; background: none; color: var(--crema); font-size: 0.9rem; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.hoja-nueva { display: block; width: 100%; margin-top: 10px; min-height: 40px; border: 0; background: none; color: var(--rojo); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.hoja-nota { font-size: 0.9rem; margin: 6px 0 8px; }
.hoja .paso button { background: #e4e1d4; }

.globos { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.globo { position: absolute; transform: translate(-50%, 0); background: var(--papel); color: var(--rojo); font-family: var(--mano); font-weight: 700; font-size: 1.35rem; line-height: 1; padding: 8px 12px 6px; border-radius: 14px; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); white-space: nowrap; animation: gritar 2.6s ease-out forwards; }
.globo.arriba { transform: translate(-50%, -100%); }
@keyframes gritar { 0% { opacity: 0; scale: 0.5; } 8% { opacity: 1; scale: 1.15; } 14% { scale: 1; } 82% { opacity: 1; } 100% { opacity: 0; } }

.aviso { position: absolute; left: 12px; right: 12px; bottom: 16px; z-index: 6; background: var(--tinta); color: var(--papel); border-radius: 10px; padding: 10px 14px; font-weight: 600; text-align: center; }

/* Pantalla ancha: la mesa a la izquierda, el maestro y las cartas a la derecha. */
@media (min-width: 900px) and (min-height: 560px) {
  .juego { max-width: 1040px; display: grid; grid-template: 'barra barra' auto 'mesa panel' 1fr / 1fr 420px; }
  .barra { grid-area: barra; }
  .mesa-caja { grid-area: mesa; }
  .panel { grid-area: panel; max-height: none; justify-content: center; padding-right: 16px; }
  .mesa[data-n='2'] { --tw: min(120px, calc((100cqh - 140px) / 3.08)); }
  .mesa[data-n='4'] { --tw: min(100px, calc((100cqh - 130px) / 4.62)); }
  .mesa[data-n='6'] { --tw: min(84px, calc((100cqh - 130px) / 3.08)); }
  .mi-carta { width: 112px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .globo { animation: none; }
}

/* Pantalla de carga */
#carga { position: fixed; inset: 0; display: grid; place-items: center; text-align: center; }
#carga p { font-family: var(--mano); font-size: 1.4rem; color: var(--crema); }
