/* El Papelito: una mesa azul, papelitos de color crema, colores por equipo. */
:root {
  --mesa: #1b3a5c;
  --mesa-2: #15304c;
  --tiza: #eaf0f6;
  --tiza-2: #a9bbcf;
  --papel: #fff6dc;
  --papel-2: #f3e6c2;
  --tinta: #1a1a1a;
  --rojo: #e03e3e;
  --verde: #2e9e6b;
  --A: #ff6b57;
  --B: #2ec4b6;
  --C: #ffb703;
  --D: #b388ff;
  --E: #7bd389;
  --F: #ff8fab;
  --G: #8ecae6;
  --H: #e9c46a;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mano: "Segoe Print", "Bradley Hand", "Noteworthy", "Chalkboard SE", cursive;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--mesa);
  color: var(--tiza);
  font: 17px/1.4 var(--font);
  -webkit-text-size-adjust: 100%;
  padding-top: env(safe-area-inset-top);
}
#app { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); min-height: 100%; }
h1 { font-size: 40px; line-height: 1; margin: 24px 0 8px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 22px; margin: 20px 0 10px; font-weight: 700; }
p { margin: 8px 0; }
.muted { color: var(--tiza-2); }
.small { font-size: 14px; }
label { display: block; font-size: 14px; color: var(--tiza-2); margin: 12px 0 4px; }
input, select {
  width: 100%; font: inherit; color: var(--tinta); background: var(--papel);
  border: 0; border-radius: 10px; padding: 12px 14px; min-height: 48px;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--C); outline-offset: 2px; }
button {
  font: inherit; font-weight: 700; color: var(--tinta); background: var(--papel);
  border: 0; border-radius: var(--radius); padding: 14px 18px; min-height: 52px;
  width: 100%; cursor: pointer; touch-action: manipulation;
}
button:active { background: var(--papel-2); }
button:disabled { opacity: 0.45; cursor: default; }
button.ghost { background: transparent; color: var(--tiza); border: 2px solid var(--tiza-2); }
button.danger { background: var(--rojo); color: #fff; }
button.ok { background: var(--verde); color: #fff; }
button.mini { width: auto; min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 10px; }
.code {
  font-size: 56px; font-weight: 800; letter-spacing: 0.18em; text-align: center;
  background: var(--mesa-2); border-radius: var(--radius); padding: 12px 0 12px 0.18em; margin: 12px 0;
}
.err { background: var(--rojo); color: #fff; border-radius: 10px; padding: 10px 14px; margin: 10px 0; }

/* equipos */
.team { border-left: 6px solid var(--tc, var(--tiza-2)); padding: 8px 12px; margin: 12px 0; background: var(--mesa-2); border-radius: 0 var(--radius) var(--radius) 0; }
.team h3 { margin: 0 0 6px; font-size: 16px; color: var(--tc, var(--tiza)); }
.player { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.player .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--verde); flex: none; }
.player.off .dot { background: var(--tiza-2); }
.player.off .name { color: var(--tiza-2); }
.player .name { flex: 1; }
.player select { width: auto; min-height: 36px; padding: 4px 8px; font-size: 14px; }
.t-A { --tc: var(--A); } .t-B { --tc: var(--B); } .t-C { --tc: var(--C); } .t-D { --tc: var(--D); }
.t-E { --tc: var(--E); } .t-F { --tc: var(--F); } .t-G { --tc: var(--G); } .t-H { --tc: var(--H); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--mesa-2); border-radius: 999px; padding: 4px 12px 4px 6px; font-weight: 700; }
.chip::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--tc, var(--tiza-2)); }

/* configuración */
.cfg { background: var(--mesa-2); border-radius: var(--radius); padding: 4px 14px 14px; }
.cfg .row label { margin-top: 12px; }
.cfg dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 10px 0 0; font-size: 15px; }
.cfg dt { color: var(--tiza-2); } .cfg dd { margin: 0; text-align: right; }

/* cabecera de turno */
.top { position: sticky; top: 0; z-index: 2; background: var(--mesa); margin: -16px -16px 12px; padding: 12px 16px 8px; display: flex; align-items: center; gap: 10px; }
.top .scores { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.top .ronda { font-size: 13px; color: var(--tiza-2); width: 100%; }
.timer { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; min-width: 3.2ch; text-align: right; }
.timer.low { color: var(--C); }
.timer.paused { color: var(--tiza-2); }

/* el papelito */
.papelito {
  background: var(--papel); color: var(--tinta); border-radius: 6px; padding: 26px 22px;
  font: 600 28px/1.25 var(--mano); text-align: center; transform: rotate(-1.5deg);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); margin: 18px 6px; position: relative; overflow-wrap: anywhere;
  animation: papel 240ms ease-out;
}
.papelito::after { content: ""; position: absolute; left: 0; right: 0; top: -3px; height: 6px;
  background: repeating-linear-gradient(90deg, var(--mesa) 0 8px, transparent 8px 14px); }
.papelito.small { font-size: 20px; padding: 14px 16px; transform: rotate(0.8deg); margin: 10px 0; }
@keyframes papel { from { transform: rotate(-1.5deg) scale(0.92); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .papelito { animation: none; } }

.who { font-size: 20px; font-weight: 700; margin: 8px 0; }
.word { font-size: 40px; font-weight: 800; text-align: center; margin: 24px 0; overflow-wrap: anywhere; }
.center { text-align: center; }
.big { font-size: 30px; font-weight: 800; }

/* lienzo */
canvas { width: 100%; aspect-ratio: 1; background: var(--papel); border-radius: 6px; touch-action: none; display: block; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); }

/* barra de acciones inferior */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; background: var(--mesa);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px;
  max-width: 520px; margin: 0 auto;
}
.actions > * { flex: 1; }

/* tarjetas de "adivinado" con protesta */
.reveals:empty { display: none; }
.reveals { position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 3; max-width: 520px; margin: 0 auto; padding: 0 16px; }
.reveal { background: var(--papel); color: var(--tinta); border-radius: 10px; padding: 10px 12px; margin-top: 8px; box-shadow: 0 8px 20px rgba(0,0,0,.4); }
.reveal .txt { font: 600 18px/1.25 var(--mano); }
.reveal .bar { height: 4px; background: var(--papel-2); border-radius: 2px; margin: 8px 0; overflow: hidden; }
.reveal .bar > i { display: block; height: 100%; background: var(--rojo); width: 100%; }
.reveal .row { gap: 8px; }
.reveal .row .muted { color: #666; font-size: 13px; }

/* superposiciones */
#overlay { position: fixed; inset: 0; z-index: 10; background: rgba(10, 22, 36, 0.92); display: flex; align-items: center; justify-content: center; padding: 24px; }
#overlay > div { max-width: 480px; width: 100%; }
#net { position: fixed; top: 0; left: 0; right: 0; z-index: 20; background: var(--C); color: var(--tinta); text-align: center; padding: 8px; font-weight: 700; }
#toast { position: fixed; top: 12px; left: 16px; right: 16px; z-index: 30; background: var(--rojo); color: #fff; border-radius: 10px; padding: 12px 14px; font-weight: 700; text-align: center; }

details.players { margin: 16px 0; }
details.players summary { cursor: pointer; color: var(--tiza-2); font-size: 14px; padding: 8px 0; }
table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 15px; }
td, th { padding: 8px 4px; text-align: right; border-bottom: 1px solid var(--mesa-2); }
td:first-child, th:first-child { text-align: left; }
.win { color: var(--C); }
.counter { font-size: 13px; color: var(--tiza-2); text-align: right; margin-top: 2px; }
.counter.bad { color: var(--C); }
