:root {
  --teal: #0b8fb3;
  --teal-2: #08b3d6;
  --teal-dark: #076a86;
  --green: #22b21a;
  --green-dark: #178a12;
  --bg: #f6f3ea;
  --card: #ffffff;
  --text: #1d2a33;
  --muted: #6b7a85;
  --line: #d9e2e7;
  --wood-1: #6b4426;
  --wood-2: #4a2c17;
  --gold: #f2c230;
  --red: #c62828;
  --team-a: #2f7de1;
  --team-b: #e2582f;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Nunito, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* Barra superior */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--teal-2), var(--teal));
  color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15);
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: .2px; }
.brand img { width: 30px; height: 30px; }
.brand b { color: var(--gold); margin-left: 4px; }
.who { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.who #whoName { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.4); padding: 4px 12px; border-radius: 999px; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; padding: 4px; }

/* Pantallas */
.screen { max-width: 1200px; margin: 0 auto; padding: 16px; }
.hero { text-align: center; padding: 24px 8px 8px; }
.hero-logo { display: block; margin: 0 auto 10px; width: 160px; height: 160px; border-radius: 28px; box-shadow: 0 8px 28px rgba(5,11,31,.35); }
.brand img { border-radius: 8px; }
.hero h1 { color: var(--teal-dark); font-size: clamp(28px, 6vw, 44px); margin: 0 0 8px; }
.hero p { color: var(--muted); font-size: 18px; margin: 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card h2 { margin: 0 0 12px; color: var(--teal-dark); font-size: 20px; }
.card h3 { margin: 18px 0 8px; font-size: 16px; color: var(--teal-dark); }
.auth-card { max-width: 420px; margin: 20px auto; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; background: #eef4f6; padding: 4px; border-radius: 10px; }
.tab { flex: 1; border: 0; background: none; padding: 9px; border-radius: 8px; font-weight: 700; color: var(--muted); }
.tab.active { background: #fff; color: var(--teal-dark); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 12px; }
label input:not([type=radio]):not([type=checkbox]) {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 16px; background: #fbfdfe;
}
/* ---------- Soporte y administración ---------- */
.badge-n {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: #e53935; color: #fff; font-size: 12px; font-weight: 800; margin-left: 6px;
}
.btn.warn { background: #f0932b; border-color: #c97112; }
.help-link { display: block; margin: 12px auto 0; font-size: 14px; color: #2f6fb5; text-align: center; }
.sup-fab {
  position: fixed; right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 40; border: 0; border-radius: 999px;
  padding: 11px 16px; background: #0b8fb3; color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 6px 18px rgba(0,0,0,.3); position: fixed;
}
.sup-fab .badge-n { margin-left: 6px; }
.support {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: #fff; display: flex; flex-direction: column;
  max-height: 82dvh; border-radius: 14px 14px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.35);
  padding-bottom: env(safe-area-inset-bottom);
}
.support[hidden] { display: none; }
@media (min-width: 700px) { .support { left: auto; right: 16px; bottom: 16px; width: 400px; border-radius: 14px; } }
.sup-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #0b8fb3; color: #fff; border-radius: 14px 14px 0 0; }
.sup-head .link { color: #fff; }
.sup-intro { padding: 8px 14px; font-size: 13px; color: var(--muted); background: #f4fafc; }
.sup-log { flex: 1; min-height: 120px; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: #fbfdfe; }
.sup-log.adm { max-height: 46dvh; border: 1px solid var(--line); border-radius: 10px; }
.sup-empty { color: var(--muted); text-align: center; padding: 18px 8px; font-size: 14px; }
.bub { max-width: 82%; border-radius: 14px; padding: 7px 11px; font-size: 15px; line-height: 1.35; word-wrap: break-word; }
.bub .bt { white-space: pre-wrap; }
.bub small { display: block; font-size: 11px; opacity: .7; margin-top: 2px; }
.bub.mio { align-self: flex-end; background: #0b8fb3; color: #fff; border-bottom-right-radius: 4px; }
.bub.otro { align-self: flex-start; background: #e6f4ea; color: #1d2a33; border-bottom-left-radius: 4px; }
.sup-form { display: grid; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.sup-form textarea, .sup-form input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 16px; resize: vertical; }
.sup-tech { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0; }
.sup-tech input { margin-top: 2px; width: auto; }
.thr { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.thr.new { border-color: #e53935; background: #fff6f5; }
.thr-top { display: flex; align-items: center; gap: 4px; }
.thr-top small { margin-left: auto; color: var(--muted); }
.thr-last { display: block; color: var(--muted); font-size: 14px; margin-top: 3px; }
.tag { background: #eef1f4; color: #555; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 8px; margin-left: 6px; }
.thr-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.thr-head small { color: var(--muted); }
.tech { background: #f6f6f6; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; margin: -2px 0 2px; }
.tech summary { cursor: pointer; font-weight: 700; color: #555; }
.tech dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0 0; }
.tech dt { font-weight: 700; color: #555; } .tech dd { margin: 0; word-break: break-word; }
.inf-err { margin-top: 6px; color: #b3261e; font-family: monospace; font-size: 11px; }
.adm-players { display: grid; gap: 8px; }
.adm-players .prow2[hidden] { display: none; }
/* Buscador de jugadores (Administración): se queda arriba al bajar por la lista */
.adm-buscar { position: sticky; top: 0; z-index: 2; display: grid; gap: 4px; padding: 6px 0 10px; background: inherit; }
.adm-buscar input { width: 100%; box-sizing: border-box; padding: 11px 14px; border: 2px solid var(--line); border-radius: 12px; font: 600 16px Nunito, system-ui, sans-serif; background: #fff; }
.adm-buscar input:focus { outline: none; border-color: #0b8fb3; }
.adm-buscar small { color: var(--muted); font-weight: 700; min-height: 1em; }
.prow2 { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; }
.prow2 .pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.prow2 small { color: var(--muted); }
.adm-temp { background: #fff8e1; border: 2px solid #f2c230; border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.temp-pw { font-family: monospace; font-size: 30px; font-weight: 800; letter-spacing: 3px; text-align: center; background: #fff; border-radius: 8px; padding: 8px; margin: 8px 0; user-select: all; }

/* Campo de contraseña con ojito */
.pw-wrap { display: flow-root; position: relative; }
.pw-wrap input { padding-right: 52px !important; }
.pw-eye {
  position: absolute; right: 4px; top: 4px; bottom: 0; width: 46px; border: 0; background: none; font-size: 22px;
  cursor: pointer; line-height: 1; border-radius: 8px;
}
.pw-eye:active { background: #e6f6fb; }
.error { color: var(--red); min-height: 1.2em; margin: 0 0 8px; font-weight: 600; }
.muted { color: var(--muted); }

.btn {
  border: 1px solid var(--teal-dark); background: var(--teal); color: #fff; font-weight: 700;
  padding: 9px 14px; border-radius: 8px;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { width: 100%; padding: 14px; font-size: 20px; }
.btn.green { background: var(--green); border-color: var(--green-dark); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn.ghost { background: #fff; color: var(--teal-dark); }

/* Salón */
.lobby-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .lobby-grid { grid-template-columns: 300px 1fr 300px; align-items: start; } }
.seg { display: flex; gap: 6px; margin-bottom: 10px; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 10px 6px; border: 2px solid var(--line); border-radius: 10px;
  font-weight: 800; cursor: pointer; background: #fbfdfe;
}
.seg small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; }
.seg input:checked + span { border-color: var(--teal); background: #e6f6fb; color: var(--teal-dark); }
.seg input:focus-visible + span { outline: 2px solid var(--teal); }
.install-banner {
  display: flex; align-items: center; gap: 12px; background: linear-gradient(180deg, #0b2a6b, #050b1f); color: #fff;
  border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; box-shadow: 0 4px 14px rgba(5,11,31,.35);
}
.install-banner img { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.install-banner .ib-text { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
.install-banner .ib-text b { display: block; font-size: 16px; }
.install-banner .ib-actions { display: flex; flex-direction: column; gap: 6px; }
.install-banner .btn { padding: 7px 12px; font-size: 14px; }
.install-banner .link { color: #9fc4ff; font-size: 12px; text-align: center; }
.practice-btn { margin-top: 8px; font-size: 16px; }
.quick-btn { font-size: 22px; padding: 12px; }
.quick-btn small { display: block; font-size: 12px; font-weight: 600; opacity: .9; margin-top: 2px; }
.watch-btn { color: var(--teal-dark); }
#watchBtn2 { margin-bottom: 12px; }
.opt-check { display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin: 0; font-weight: 600; font-size: 14px; background: #fff; border-top: 1px solid #d2d9df; }
.gcard .watch-card { margin: 8px auto; min-width: 60%; font-size: 15px; }
.gcard .viewers { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; padding-bottom: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.code-form { display: flex; gap: 6px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.code-form input { flex: 1; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

.table-list { display: grid; gap: 10px; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
.tcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; background: #fbfdfe; }
.tcard .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 800; }
.badge { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #e6f6fb; color: var(--teal-dark); }
.badge.play { background: #fff1d6; color: #8a5a00; }
.seats { display: flex; flex-wrap: wrap; gap: 6px; }
.seat-chip {
  flex: 1 1 120px; display: flex; align-items: center; gap: 6px; border-radius: 8px; padding: 6px 8px;
  border: 1px solid var(--line); background: #fff; font-weight: 700; min-height: 38px; font-size: 14px;
}
.seat-chip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.seat-chip.free { border-style: dashed; color: var(--teal-dark); justify-content: center; }
button.seat-chip.free:hover { background: #e6f6fb; }
.team-a { background: var(--team-a); }
.team-b { background: var(--team-b); }

.ranking { margin: 0; padding-left: 26px; }
.ranking li { padding: 5px 0; border-bottom: 1px solid #eef2f4; display: flex; justify-content: space-between; gap: 8px; }
.ranking li span:last-child { color: var(--muted); font-weight: 700; }
.rules { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- Salón estilo Ludoteka ---------- */
#lobby { max-width: 760px; }
.ltabs { display: flex; gap: 6px; background: #5f7283; padding: 8px 8px 0; border-radius: 10px 10px 0 0; }
.ltab {
  flex: 1; border: 0; border-radius: 8px 8px 0 0; background: #e3e8ec; color: #3d4a55; font-weight: 800;
  padding: 10px 6px; font-size: 15px; line-height: 1.2;
}
.ltab small { display: block; font-weight: 700; color: #6b7a85; }
.ltab .ico { margin-right: 2px; }
.ltab.active { background: #fffdf3; color: #2b3640; }
.lpanel { background: #fffdf3; border: 1px solid #d8dccf; border-top: 0; border-radius: 0 0 10px 10px; padding: 14px; }

.open-form { display: grid; gap: 14px; }
.opt { border: 1px solid #c9d2da; border-radius: 8px; padding: 0; margin: 0; background: #e8eef3; overflow: hidden; }
.opt legend {
  float: left; width: 100%; background: #6d7f8f; color: #fff; padding: 6px 12px; font-weight: 700; font-size: 15px;
}
.opt legend + * { clear: both; }
.opt-grid, .opt-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; }
.opt-row > .pick { flex: 1 1 0; min-width: 0; }
.opt-row.four > .pick { flex: 1 1 22%; }
.pick { margin: 0; cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick > span {
  display: flex; align-items: center; justify-content: center; gap: 6px; flex-direction: column; text-align: center;
  background: #fff; border: 2px solid #d2d9df; border-radius: 8px; padding: 8px 6px; font-weight: 700; color: #2b3640;
  min-height: 52px; height: 100%;
}
.pick.text > span { flex-direction: row; flex-wrap: wrap; }
.opt-row.four .pick > span { flex-direction: column; font-size: 13px; }
.pick small { color: var(--muted); font-weight: 600; font-size: 11px; display: block; width: 100%; }
.pick input:checked + span { border-color: #c62828; box-shadow: 0 0 0 1px #c62828; }
.pick input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 2px; }
.pick .gicon { width: 64px; height: 64px; padding: 6px; }
.opt-foot { background: #fff; padding: 8px 12px; border-top: 1px solid #d2d9df; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; }
/* Rango cercano: título arriba y debajo  [−] [insignia] a [insignia] [+], todo en una línea y centrado */
.opt-level { display: grid; gap: 8px; padding: 0 10px 12px; font-weight: 600; }
.lvl-tit { font-weight: 800; }
.lvl-tit small { display: block; color: var(--muted); font-weight: 600; font-size: 13px; }
.lvl-ctrl { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.lvl-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid #c9d2da; background: #fff; color: var(--teal); font: 900 22px Nunito, system-ui, sans-serif; cursor: pointer; }
.lvl-btn:disabled { opacity: .35; cursor: default; }
.lvl-box { min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; border: 1px solid #c9d2da; border-radius: 12px; padding: 6px 8px; font-weight: 800; color: var(--muted); }
.lvl-box .lvl-todos { color: #1f7a2e; font-size: 16px; }
/* Insignia pequeña con el escalón en estrellas (en lugar de nombres) */
.rg-rango { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; }
.rmini { display: inline-grid; justify-items: center; gap: 1px; line-height: 1; }
.rmini small { font-size: 10px; letter-spacing: 1px; color: #c9971c; min-height: 10px; }
.play-btn { display: flex; align-items: center; justify-content: center; gap: 10px; background: #5cb85c; border-color: #3e8e3e; }
.play-btn .gicon.small { width: 40px; height: 40px; background: #fff; border-radius: 6px; padding: 2px; }

.gicon { display: inline-block; width: 48px; height: 48px; flex: none; }
.gicon svg { width: 100%; height: 100%; display: block; }
.gicon.tiny { width: 28px; height: 28px; margin-left: auto; }

.round {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  font-size: 17px; flex: none; border: 2px solid transparent;
}
.round.blue { background: #2f4fbf; } .round.gray { background: #7d7d7d; } .round.sky { background: #3aa0e6; }
.round.green { background: #2fa84f; } .round.orange { background: #f0932b; } .round.red { background: #e53935; }
.pick .round { width: 30px; height: 30px; font-size: 15px; }

.people { display: inline-flex; gap: 1px; align-items: flex-end; }
.people i { width: 9px; height: 15px; border-radius: 5px 5px 2px 2px; display: inline-block; position: relative; }
.people i::before { content: ''; position: absolute; top: -7px; left: 1px; width: 7px; height: 7px; border-radius: 50%; background: inherit; }
.people i.pa { background: #1f2f86; } .people i.pb { background: #d32f2f; }
.people { padding-top: 7px; }

/* Distintivo del rango (en lugar del escudo verde): una ficha de pie; arriba el metal del rango, abajo 1, 2 o 3 puntos (I, II, III) */
.shield { display: inline-grid; grid-template-rows: 1fr 1fr; width: 15px; height: 27px; flex: none; vertical-align: middle;
  border-radius: 4px; background: #fbf7ec; border: 1.5px solid #cfc6ae; overflow: hidden; box-shadow: 0 1px 1px rgba(0,0,0,.18); }
.shield .rg-top { background: var(--rc, #8e9aa3); }
.shield .rg-bot { display: flex; align-items: center; justify-content: center; gap: 1.5px; border-top: 1.5px solid #cfc6ae; }
.shield .rg-bot i { width: 3px; height: 3px; border-radius: 50%; background: #1d2a33; }
.shield.r1 { --rc: linear-gradient(135deg, #c9d2d8, #8e9aa3); }
.shield.r2 { --rc: linear-gradient(135deg, #e2a26b, #9c5a2a); }
.shield.r3 { --rc: linear-gradient(135deg, #f1f4f6, #9fabb4); }
.shield.r4 { --rc: linear-gradient(135deg, #f6d86b, #c9971c); }
.shield.r5 { --rc: linear-gradient(135deg, #d7f1ef, #5fa9a4); }
.shield.r6 { --rc: linear-gradient(135deg, #bfe3ff, #3f7fe0); }
.shield.r7 { --rc: linear-gradient(135deg, #7b2ff7, #1d2a33); }
/* Insignia grande del rango: imagen con fondo oscuro; el borde se desvanece en círculo */
.insignia { display: block; flex: none; border-radius: 50%; background: #0b1020; object-fit: cover;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 58%, transparent 71%); mask-image: radial-gradient(circle at 50% 50%, #000 58%, transparent 71%); }
.shield.big { width: 24px; height: 42px; border-radius: 6px; }
.shield.big .rg-bot i { width: 5px; height: 5px; }

/* Partidas */
.table-list { display: grid; gap: 12px; }
.gcard { display: grid; grid-template-columns: 1fr 1.15fr; gap: 10px; border: 2px solid #c98a73; border-radius: 10px; background: #fdeee2; padding: 10px; }
.gcard.mano { border-color: #c9b26f; background: #fdf8e2; }
.ginfo { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 6px 8px; align-content: space-between; }
.gtitle { display: flex; flex-direction: column; line-height: 1.15; }
.gtitle b { font-size: 20px; } .gtitle i { font-size: 15px; } .gtitle small { color: var(--muted); font-weight: 700; margin-top: 2px; }
.gicons { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gseats { background: #e7f0e8; border: 1px solid #b8cbb9; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.srow { display: flex; align-items: center; gap: 6px; padding: 5px 8px; min-height: 38px; border-bottom: 1px solid #cfdccf; font-weight: 700; font-size: 15px; }
.srow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.srow .ok { color: #1f7a2e; }
.srow .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.srow.empty-seat { color: var(--muted); font-size: 13px; font-weight: 600; }
.gseats .btn { margin: 8px auto; min-width: 60%; font-size: 17px; }
.gseats .playing { text-align: center; padding: 10px; color: #8a5a00; font-weight: 800; }
@media (max-width: 480px) { .gcard { grid-template-columns: 1fr; } }

/* Jugadores */
.player-list { display: grid; gap: 6px; }
.prow { display: flex; align-items: center; gap: 8px; background: #dcebf8; border: 1px solid #b9cfe3; border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 16px; }
.prow.me { background: #fff6d6; border-color: #e6cf7a; }
.prow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 6px; flex: none;
  background: #fff; border: 1px solid #c9d2da; font-weight: 800; font-size: 18px; color: var(--teal-dark);
}
.avatar.big { width: 52px; height: 52px; font-size: 30px; background: #3a3a3a; color: #fff; }
.ranking li { align-items: center; }
.ranking li .nm { flex: 1; font-weight: 700; }

/* Menú del usuario */
.who { position: relative; }
.who-btn {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.55);
  color: #fff; border-radius: 10px; padding: 4px 12px 4px 4px; font-weight: 800; font-size: 16px;
}
.who-btn .avatar { width: 30px; height: 30px; font-size: 16px; background: #3a3a3a; color: #fff; border: 0; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 20; background: #fff; border: 1px solid #c9d2da; border-radius: 6px;
  padding: 12px; display: grid; gap: 8px; min-width: 190px; box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
.user-menu::before { content: ''; position: absolute; top: -8px; right: 26px; width: 14px; height: 14px; background: #fff; border-left: 1px solid #c9d2da; border-top: 1px solid #c9d2da; transform: rotate(45deg); }
.user-menu .btn { background: #3f78c0; border-color: #2f5f9e; font-weight: 600; }
.user-menu .btn.danger { background: #d9534f; border-color: #b52b27; }

/* Perfil e historial */
.screen.narrow { max-width: 640px; }
.page-head { align-items: center; margin: 4px 0 10px; }
.page-head h1 { color: var(--teal-dark); margin: 0; font-size: 28px; }
.pstats { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.pstats span:not(.shield) { color: var(--muted); font-weight: 600; }
.sec { margin: 22px 0 8px; font-size: 18px; }
.ptable { border: 1px solid #c9ced3; background: #fff; }
.ph { background: #eeeeee; padding: 12px 14px; font-weight: 800; color: #3d3d3d; font-size: 17px; }
.pr { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #c9ced3; font-size: 17px; flex-wrap: wrap; }
.pr .btn.ghost { color: #555; border-color: #c9ced3; font-weight: 600; }
.pedit { padding: 12px 14px; background: #f7fbfd; border-top: 2px solid var(--teal); }
.pedit-actions { display: flex; gap: 8px; }
.radios { display: flex; gap: 14px; flex-wrap: wrap; }
.radios label { display: flex; align-items: center; gap: 4px; margin: 0; font-weight: 600; font-size: 16px; }
.flags .flag { font-size: 30px; margin-right: 6px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; margin: 6px 0 10px; }
.icon-pick { font-size: 26px; height: 46px; border: 2px solid #d2d9df; border-radius: 8px; background: #fff; }
.icon-pick.on { border-color: #c62828; box-shadow: 0 0 0 1px #c62828; }
.small-note { font-size: 13px; margin-top: 10px; }
.back-link { color: #2f6fb5; text-decoration: none; font-size: 18px; margin: 4px 0 10px; }
.hform { background: #e8eef3; border: 1px solid #c9d2da; border-radius: 8px; overflow: hidden; max-width: 520px; margin: 0 auto 16px; }
.hf-title { background: #6d7f8f; color: #fff; text-align: center; padding: 9px; font-size: 18px; }
.hf-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; padding: 8px 12px; margin: 0; border-bottom: 1px solid #d6dde3; font-size: 16px; }
.hf-row span { font-weight: 800; color: #4a5560; }
.hf-row input, .hf-row select { width: 100%; padding: 9px 10px; border: 1px solid #9aa6b0; border-radius: 4px; font-size: 16px; background: #fff; }
.hf-actions { padding: 12px; text-align: center; }
.hf-btn { background: #24578f; border-color: #1b4370; min-width: 60%; font-weight: 600; font-size: 17px; }
.hbox { border: 1px solid #c9d2da; border-radius: 6px; overflow: hidden; margin-bottom: 14px; background: #f6f6f6; }
.hbox-title { background: #6d7f8f; color: #fff; padding: 9px 14px; font-size: 17px; }
.hsum { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-bottom: 2px solid #c9d2da; background: #f1f1f1; padding: 10px 14px; text-align: left; font-size: 16px; }
.hsum.head { background: #fff; justify-content: space-between; font-size: 19px; }
.hsum.sel { background: #fff6d6; }
.hsum .hs-name { flex: 1; font-size: 19px; font-weight: 800; }
.hsum .hs-name small { display: block; font-size: 15px; font-weight: 800; color: #333; }
.hs-chips { display: flex; gap: 6px; }
.chip { border: 1px solid #c9ced3; background: #e9e9e9; border-radius: 4px; padding: 5px 8px; font-weight: 800; white-space: nowrap; }
.hbox.stats { background: #efefef; padding: 12px 16px; font-size: 16px; }
.hbox.stats p { margin: 6px 0; line-height: 1.6; }
.hbox.stats .shield { vertical-align: middle; }
.hmonths { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; color: #2f6fb5; margin: 8px 0; }
.hmonths b { color: #333; }
.hbars { display: flex; justify-content: center; gap: 28px; height: 150px; align-items: flex-end; border-bottom: 2px solid #bbb; margin: 14px auto 28px; max-width: 260px; padding: 0 10px; }
.hbar { width: 70px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.hbar .bar { width: 100%; min-height: 2px; }
.hbar .bar.win { background: #8fd18f; border: 2px solid #3e9e3e; border-bottom: 0; }
.hbar .bar.loss { background: #d39090; border: 2px solid #a33; border-bottom: 0; }
.hbar span { font-weight: 800; margin-bottom: 2px; }
.hbar small { position: absolute; bottom: -24px; color: #555; font-size: 14px; }
.up { color: #1f7a2e; } .down { color: #c62828; }
.hist-list { display: grid; gap: 8px; }
.hrow2 { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-left: 5px solid #2fa84f; border-radius: 8px; padding: 8px 10px; }
.hrow2.lost { border-left-color: #d9534f; }
.hrow2 .hmain { flex: 1; min-width: 0; font-size: 15px; }
.hrow2 .hside { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.hrow2 .hside small { width: 100%; text-align: right; color: var(--muted); }
.hrow2 .round { width: 26px; height: 26px; font-size: 13px; }

/* La mesa de juego está en mesa.css */

/* Aviso de conexión caída (app.js: avisoConexion) — arriba al centro, por encima de la mesa */
#avisoConexion { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 9999;
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: #c62828; color: #fff;
  font: 800 14px Nunito, system-ui, sans-serif; box-shadow: 0 4px 14px rgba(0,0,0,.35); pointer-events: none; }
#avisoConexion[hidden] { display: none; }
#avisoConexion .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: avisoGira .8s linear infinite; }
@keyframes avisoGira { to { transform: rotate(360deg); } }

/* ---------- B1: cara propia (caras.js) ---------- */
.cg-svg svg { width: 100%; height: 100%; display: block; border-radius: 50%; }
.cara-tipos { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cara-tipo { flex: 1 1 30%; min-width: 96px; border: 2px solid #d6dee4; background: #fff; border-radius: 12px; padding: 9px 6px; font: 800 14px Nunito, system-ui, sans-serif; cursor: pointer; }
.cara-tipo.on { border-color: var(--teal); background: #e3f3f8; color: #0b6f86; }
.cara-bloque { display: grid; gap: 10px; }
.cara-fila { display: flex; gap: 12px; align-items: center; }
.cara-prev { width: 96px; height: 96px; border-radius: 50%; overflow: hidden; flex: none; background: #eef1f4; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.cara-prev img { width: 100%; height: 100%; object-fit: cover; }
.cara-av svg { width: 100%; height: 100%; }
.cara-vacia { font-size: 34px; opacity: .5; }
.cara-ok { color: #1f7a2e; font-weight: 800; }
.cara-pend { color: #8a6100; font-weight: 800; }
.cara-rech { color: #c62828; font-weight: 700; margin: 6px 0 0; }
.cara-normas summary { cursor: pointer; font-weight: 800; }
.cara-normas ul { margin: 6px 0 0 18px; padding: 0; }
.cara-acepto { font-weight: 700; display: flex; gap: 6px; align-items: center; }
.cara-botones { display: flex; gap: 8px; flex-wrap: wrap; }
.cara-subir[aria-disabled="true"] { opacity: .5; }
.av-piezas { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.av-pieza { display: grid; gap: 3px; font-size: 13px; font-weight: 700; }
.av-pieza select { padding: 6px; border-radius: 8px; border: 1px solid #c9d3da; font: inherit; }
.adm-caras { display: grid; gap: 10px; }
.adm-cara { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; background: #fff; border-radius: 12px; padding: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.adm-cara img { width: 120px; height: 120px; object-fit: cover; border-radius: 50%; grid-row: span 2; }
.adm-cara-info { display: grid; } .adm-cara-info small { color: var(--muted); }
.adm-cara-btns { display: flex; gap: 6px; flex-wrap: wrap; }
