/* ===== El menú ===== */
@property --giro {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

#menu {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: grid;
  place-items: center;
  overflow: hidden auto;
  /* Detrás, el tablero de verdad recorrido por la cámara de cine (`scene/attract.js`). Antes, negro. */
  background: transparent;
  color: #f4ead7;
  --nivel: 30%;
  --tono-nivel: 130;
  --oro: #f8c451;
  --oro-claro: #fff1bf;
  --oro-oscuro: #b35d0c;
  --filo: rgba(255, 214, 140, 0.22);
}
#menu[hidden] { display: none; }
/* Con el menú abierto, el HUD de la partida no se ve (antes lo tapaba el fondo negro del menú). */
#hud { transition: opacity 0.6s ease; }
body.en-menu #hud { opacity: 0; pointer-events: none; }
/* Los cortes a negro entre toma y toma: tapan el tablero, no el menú. */
#menu-velo { position: fixed; inset: 0; background: #000; opacity: 1; pointer-events: none; }
/* La viñeta: oscurece los bordes y el pie, para que el menú se lea sobre cualquier toma. */
.menu-vineta {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 80% at 50% 42%, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0.5) 76%, rgba(0, 0, 0, 0.85) 100%),
    linear-gradient(180deg, rgba(4, 6, 14, 0.4) 0%, rgba(4, 6, 14, 0) 28%, rgba(4, 6, 14, 0) 52%, rgba(4, 6, 14, 0.62) 100%);
}
#menu-chispas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.menu-luz { display: none; }
@keyframes luz {
  0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(0.95); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
}
.menu-caja {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2vh, 18px);
  width: min(540px, 100% - 32px);
  padding: max(16px, env(safe-area-inset-top)) 0 max(20px, env(safe-area-inset-bottom));
}

/* LA MARCA: el escudo, con su resplandor detrás y un brillo que lo cruza, y el lema. */
.menu-marca { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.menu-marca::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 44%;
  width: 150%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(255, 150, 40, 0.32), rgba(255, 110, 20, 0.1) 50%, transparent 72%);
  animation: luz 7s ease-in-out infinite;
  pointer-events: none;
}
.menu-logo-marco {
  position: relative;
  height: clamp(130px, 24vh, 290px);
  aspect-ratio: 765 / 848;
  max-width: 88vw;
  animation: flota 6s ease-in-out infinite;
}
.menu-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 26px rgba(255, 150, 40, 0.45)) drop-shadow(0 12px 22px rgba(0, 0, 0, 0.95));
}
/* El brillo que cruza el escudo, recortado con la forma del propio logo. */
.menu-logo-marco::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 252, 230, 0.9) 50%, transparent 62%);
  background-size: 320% 100%;
  background-position: 150% 0;
  -webkit-mask: url(../../assets/ui/logo.webp) center / contain no-repeat;
  mask: url(../../assets/ui/logo.webp) center / contain no-repeat;
  mix-blend-mode: soft-light;
  animation: destello-logo 6s ease-in-out 2s infinite;
  pointer-events: none;
}
@keyframes destello-logo { 0%, 62% { background-position: 150% 0; } 100% { background-position: -60% 0; } }
@keyframes flota {
  0%, 100% { transform: translateY(0) rotate(-0.6deg); }
  50% { transform: translateY(-8px) rotate(0.6deg); }
}
.menu-titulo { display: none; margin: 0; font: 900 44px/1 Georgia, serif; letter-spacing: 0.08em; color: #f5b73a; }
#menu.sin-logo .menu-logo-marco { display: none; }
#menu.sin-logo .menu-titulo { display: block; }
.menu-lema {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font: 650 clamp(10px, 2.6vw, 12.5px)/1.2 system-ui, sans-serif;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(255, 224, 168, 0.9);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.95);
}
.menu-lema::before, .menu-lema::after {
  content: '';
  width: clamp(22px, 7vw, 56px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 210, 130, 0.85));
}
.menu-lema::after { transform: scaleX(-1); }

/* EL PANEL: cristal oscuro sobre la escena, con un filo dorado. */
.menu-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.8vh, 16px);
  width: 100%;
  padding: clamp(14px, 2.4vh, 20px) clamp(14px, 3.6vw, 22px) clamp(16px, 2.6vh, 22px);
  border-radius: 26px;
  background: linear-gradient(165deg, rgba(24, 28, 46, 0.6), rgba(6, 8, 16, 0.74));
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 0 0 1px var(--filo), 0 30px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.menu-panel::before {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 222, 150, 0.95), transparent);
}

/* CONTINUAR: la partida a medias, arriba del todo, dorada como JUGAR y con su resumen debajo. */
.continuar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 18px 12px 12px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(64, 40, 10, 0.94), rgba(18, 10, 2, 0.96));
  color: #f4ead7;
  font: inherit;
  text-align: start;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255, 210, 120, 0.75), 0 0 26px rgba(255, 160, 30, 0.4), inset 0 0 22px rgba(255, 150, 30, 0.12);
  animation: late-continuar 1.8s ease-in-out infinite;
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1);
  -webkit-tap-highlight-color: transparent;
}
@keyframes late-continuar {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 210, 120, 0.7), 0 0 20px rgba(255, 160, 30, 0.35), inset 0 0 22px rgba(255, 150, 30, 0.12); }
  50% { box-shadow: 0 0 0 2px rgba(255, 230, 160, 0.95), 0 0 42px rgba(255, 170, 40, 0.7), inset 0 0 26px rgba(255, 150, 30, 0.2); }
}
.continuar[hidden] { display: none; }
.continuar:hover { transform: scale(1.03); }
.continuar:active { transform: scale(0.97); }
.continuar.pulsado { animation: pulsado 0.6s ease-out forwards; }
.continuar-icono {
  flex: none;
  width: 48px;
  height: 48px;
  padding: 11px 9px 11px 13px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff1bf 0%, #f8c451 38%, #e08a1c 70%, #b35d0c 100%);
  fill: #2a1400;
  box-shadow: 0 0 16px rgba(255, 170, 40, 0.7), inset 0 -3px 8px rgba(110, 45, 0, 0.45);
}
.continuar-textos { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.continuar-titulo { font: 900 clamp(17px, 4.8vw, 21px)/1.1 system-ui, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: #ffd98a; }
.continuar-sub { font-size: 12.5px; line-height: 1.35; opacity: 0.78; }

/* Las dos tarjetas de modo. */
.menu-modos { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.modo {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px 14px;
  border: 1px solid rgba(255, 214, 140, 0.14);
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(34, 36, 58, 0.78), rgba(8, 10, 20, 0.88));
  color: #e9dcc0;
  font: inherit;
  cursor: pointer;
  opacity: 0.66;
  transform: translateZ(0);
  transition: transform 0.25s cubic-bezier(0.2, 1.4, 0.4, 1), opacity 0.25s, box-shadow 0.3s;
  -webkit-tap-highlight-color: transparent;
}
.modo::before {
  content: '';
  position: absolute;
  inset: -2px;
  padding: 2px;
  border-radius: 19px;
  /* Un destello dorado que recorre el borde de la elegida. */
  background: conic-gradient(from var(--giro), rgba(255, 190, 80, 0.15) 0deg, #ffd56b 50deg, #fff4cf 70deg, #e08a1c 95deg, rgba(255, 190, 80, 0.15) 150deg, rgba(255, 190, 80, 0.15) 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s;
  animation: giro 3s linear infinite;
  pointer-events: none;
}
@keyframes giro { to { --giro: 360deg; } }
.modo[aria-checked="true"] {
  opacity: 1;
  color: #fff;
  background: linear-gradient(165deg, rgba(70, 48, 16, 0.82), rgba(16, 10, 4, 0.9));
  box-shadow: 0 0 28px rgba(255, 160, 40, 0.35), inset 0 0 24px rgba(255, 170, 50, 0.14);
  transform: translateY(-3px) scale(1.03);
}
.modo[aria-checked="true"]::before { opacity: 1; }
.modo:hover { opacity: 1; transform: translateY(-4px) scale(1.04); }
.modo:active { transform: scale(0.96); }
.modo.toque { animation: toque 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes toque { 0% { transform: scale(0.9); } 100% { transform: translateY(-3px) scale(1.03); } }
.modo-icono {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: #ffd98a;
  filter: drop-shadow(0 0 6px rgba(255, 180, 60, 0.75));
}
.modo[aria-checked="true"] .modo-icono { animation: icono 2.4s ease-in-out infinite; }
@keyframes icono { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.modo-titulo { font: 800 clamp(16px, 4.4vw, 20px)/1.1 system-ui, sans-serif; letter-spacing: 0.02em; }
.modo-sub { font-size: 12px; opacity: 0.7; }

/* Lo de la CPU (con qué piezas y a qué nivel): se despliega al elegir la CPU. */
.menu-cpu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: max-height 0.45s ease, opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.menu-cpu.abierto { max-height: 260px; opacity: 1; transform: none; }
.menu-nivel { width: 100%; }
.menu-fila { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; width: 100%; }
.menu-etiqueta { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8; white-space: nowrap; }
.piezas { display: flex; flex-wrap: wrap; gap: 6px; }
.pieza-op {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 214, 140, 0.2);
  border-radius: 999px;
  background: rgba(8, 10, 20, 0.7);
  color: #e9dcc0;
  font: 600 13px/1 system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1), box-shadow 0.2s, border-color 0.2s;
}
.pieza-op:hover { transform: translateY(-2px); }
.pieza-op[aria-checked="true"] { border-color: #ffc451; color: #fff; box-shadow: 0 0 14px rgba(255, 160, 40, 0.5); }
.pieza-ico { font-size: 17px; line-height: 1; }
.pieza-op[data-color="black"] .pieza-ico { color: #111; text-shadow: 0 0 1px #fff, 0 0 5px rgba(255, 255, 255, 0.7); }
.pieza-ico.mirar { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.pieza-ico.azar { width: 15px; height: 15px; border-radius: 50%; background: linear-gradient(90deg, #f4ead7 50%, #111 50%); box-shadow: 0 0 0 1.5px #cfe0ff; }

/* Los nombres: en 1 contra 1, los dos; online, el mío. Se despliegan como lo de la CPU. A 16 px, que el
   iPhone no acerque la página al escribir. */
.menu-nombres {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: max-height 0.45s ease, opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.menu-nombres.abierto { max-height: 80px; opacity: 1; transform: none; }
.menu-nombres[data-modo="online"] { grid-template-columns: 1fr; }
.nombre-campo {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid rgba(255, 214, 140, 0.22);
  border-radius: 999px;
  background: rgba(8, 10, 20, 0.7);
  cursor: text;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.nombre-campo[hidden] { display: none; }
.nombre-campo:focus-within { border-color: #ffc451; box-shadow: 0 0 14px rgba(255, 160, 40, 0.45); }
.nombre-campo input {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: 600 16px/1.2 system-ui, sans-serif;
  outline: none;
}
.nombre-campo input::placeholder { color: rgba(233, 220, 192, 0.5); }
.nombre-campo[data-lado="black"] .pieza-ico { color: #111; text-shadow: 0 0 1px #fff, 0 0 5px rgba(255, 255, 255, 0.7); }
.nombre-ico { width: 18px; height: 18px; flex: none; fill: none; stroke: #e9dcc0; stroke-width: 2; stroke-linecap: round; }

/* La duración: pestañas por ritmo y sus tiempos. */
.menu-tiempo { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.tiempo-elegido { font-weight: 700; color: #ffd66b; text-shadow: 0 0 10px rgba(255, 190, 60, 0.55); white-space: nowrap; }
.tiempo-categorias { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(6, 8, 16, 0.55); border: 1px solid rgba(255, 214, 140, 0.14); }
.tiempo-cat {
  flex: 1;
  padding: 8px 2px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #c9b998;
  font: 700 clamp(11px, 3.1vw, 13px)/1 system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}
.tiempo-cat[aria-selected="true"] { background: linear-gradient(180deg, #ffd875, #d98a20); color: #2a1400; box-shadow: 0 0 14px rgba(255, 160, 40, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.tiempo-opciones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; animation: aparece 0.35s ease; }
.tiempo-opciones[hidden] { display: none; }
.tiempo-op {
  padding: 9px 4px;
  border: 1px solid rgba(255, 200, 90, 0.28);
  border-radius: 10px;
  background: rgba(24, 16, 6, 0.85);
  color: #f3dfb3;
  font: 800 15px/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1), box-shadow 0.2s, border-color 0.2s;
}
.tiempo-op:hover { transform: translateY(-2px); }
.tiempo-op[aria-checked="true"] { border-color: #ffc451; color: #fff; box-shadow: 0 0 16px rgba(255, 170, 40, 0.6); }

/* El idioma: la bandera arriba y, al tocarla, la lista. */
.menu-idioma { position: absolute; top: max(14px, env(safe-area-inset-top)); inset-inline-end: max(14px, env(safe-area-inset-right)); z-index: 2; }
.idioma-boton {
  display: grid;
  place-items: center;
  width: 46px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 214, 140, 0.35);
  border-radius: 8px;
  background: rgba(8, 10, 20, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 160, 40, 0.25);
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.idioma-boton:hover { transform: scale(1.08); }
.bandera { display: block; width: 30px; height: 20px; }
.idiomas {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 170px;
  padding: 6px;
  border: 1px solid rgba(90, 160, 255, 0.35);
  border-radius: 12px;
  background: rgba(8, 12, 26, 0.97);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 18px rgba(0, 120, 255, 0.3);
  animation: aparece 0.25s ease;
}
.idiomas[hidden] { display: none; }
.idioma {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e3ecff;
  font: 600 15px/1 system-ui, sans-serif;
  text-align: start;
  cursor: pointer;
}
.idioma:hover, .idioma:focus-visible { background: rgba(40, 110, 255, 0.25); }
.idioma[aria-selected="true"] { background: rgba(40, 110, 255, 0.35); }
.nivel-cabecera { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.nivel-cabecera label { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8; }
.nivel-numero { font: 900 34px/1 system-ui, sans-serif; color: hsl(var(--tono-nivel), 100%, 62%); text-shadow: 0 0 14px hsla(var(--tono-nivel), 100%, 55%, 0.8); }
#menu-nivel-valor { display: inline-block; }
#menu-nivel-valor.salta { animation: salta 0.25s ease-out; }
@keyframes salta { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
#menu-nivel-rango {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  margin: 6px 0;
  border-radius: 999px;
  background:
    linear-gradient(90deg, #00d2ff, hsl(var(--tono-nivel), 100%, 55%)) 0 / var(--nivel) 100% no-repeat,
    #141a2c;
  box-shadow: 0 0 14px hsla(var(--tono-nivel), 100%, 50%, 0.45), inset 0 1px 3px rgba(0, 0, 0, 0.6);
  outline: none;
  cursor: pointer;
}
#menu-nivel-rango::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, hsl(var(--tono-nivel), 100%, 70%) 45%, hsl(var(--tono-nivel), 100%, 45%));
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15), 0 0 18px hsla(var(--tono-nivel), 100%, 60%, 0.9);
  transition: transform 0.15s;
}
#menu-nivel-rango:active::-webkit-slider-thumb { transform: scale(1.2); }
#menu-nivel-rango::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, hsl(var(--tono-nivel), 100%, 70%) 45%, hsl(var(--tono-nivel), 100%, 45%));
  box-shadow: 0 0 18px hsla(var(--tono-nivel), 100%, 60%, 0.9);
}
#menu-nivel-rango:focus-visible { box-shadow: 0 0 0 3px rgba(120, 200, 255, 0.6); }
.nivel-nombre { margin-top: 8px; text-align: center; font-weight: 700; letter-spacing: 0.06em; color: hsl(var(--tono-nivel), 90%, 72%); }

/* JUGAR: late, le cruza un brillo y al pulsarlo revienta. */
.jugar {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: 4px;
  padding: clamp(16px, 2.6vh, 20px) 24px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff1bf 0%, #f8c451 38%, #e08a1c 70%, #b35d0c 100%);
  color: #2a1400;
  font: 900 clamp(22px, 6vw, 30px)/1 system-ui, sans-serif;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255, 226, 150, 0.7), 0 0 28px rgba(255, 160, 30, 0.55), inset 0 -5px 12px rgba(110, 45, 0, 0.45), inset 0 3px 6px rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.8);
  animation: late 1.8s ease-in-out infinite;
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1);
  -webkit-tap-highlight-color: transparent;
}
.jugar::before {
  content: '';
  position: absolute;
  top: -60%;
  left: -70%;
  width: 45%;
  height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  transform: skewX(-22deg);
  animation: brillo 2.8s ease-in-out infinite;
}
.jugar span { position: relative; }
@keyframes brillo { 0%, 55% { left: -70%; } 100% { left: 140%; } }
@keyframes late {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 226, 150, 0.7), 0 0 24px rgba(255, 160, 30, 0.45), inset 0 -5px 12px rgba(110, 45, 0, 0.45), inset 0 3px 6px rgba(255, 255, 255, 0.6); }
  50% { box-shadow: 0 0 0 3px rgba(255, 236, 170, 0.9), 0 0 54px rgba(255, 170, 40, 0.85), inset 0 -5px 12px rgba(110, 45, 0, 0.45), inset 0 3px 6px rgba(255, 255, 255, 0.6); }
}
.jugar:hover { transform: scale(1.06); }
.jugar:active { transform: scale(0.95); }
.jugar.pulsado { animation: pulsado 0.6s ease-out forwards; }
@keyframes pulsado {
  0% { transform: scale(0.94); filter: brightness(1); }
  30% { transform: scale(1.18); filter: brightness(1.8); }
  100% { transform: scale(1.4); filter: brightness(2.4); opacity: 0; }
}

/* ENTRADA. El escudo cae de golpe desde la cámara con un fogonazo detrás; el lema se abre; el panel sube y
   lo de dentro llega cada cosa a su tiempo. SALIDA: el escudo sube, el panel baja, y la viñeta se va mientras
   la cámara de cine baja en vuelo hasta la partida. */
#menu.entra .menu-logo-marco { animation: logo-entra 1.15s cubic-bezier(0.2, 1.2, 0.35, 1) 0.15s both, flota 6s ease-in-out 1.3s infinite; }
@keyframes logo-entra {
  0% { opacity: 0; transform: scale(1.9) translateY(-20px); filter: blur(16px) brightness(2.6); }
  45% { opacity: 1; transform: scale(0.94); filter: blur(0) brightness(1.7); }
  70% { transform: scale(1.03); filter: brightness(1.15); }
  100% { transform: none; filter: none; }
}
#menu.entra .menu-marca::before { animation: fogonazo 1.4s ease-out 0.55s both, luz 7s ease-in-out 1.95s infinite; }
@keyframes fogonazo {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.25); filter: brightness(2.2); }
  100% { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
}
#menu.entra .menu-lema { animation: lema-entra 1s cubic-bezier(0.2, 1, 0.3, 1) 0.75s both; }
@keyframes lema-entra { from { opacity: 0; letter-spacing: 0.9em; } }
#menu.entra .menu-panel { animation: panel-entra 0.9s cubic-bezier(0.2, 1.1, 0.3, 1) 0.55s both; }
@keyframes panel-entra { from { opacity: 0; transform: translateY(40px) scale(0.96); } }
#menu.entra .modo { animation: tarjeta 0.8s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
#menu.entra .modo:nth-child(1) { animation-delay: 0.8s; --desde: -40px; }
#menu.entra .modo:nth-child(2) { animation-delay: 0.92s; --desde: 0px; }
#menu.entra .modo:nth-child(3) { animation-delay: 1.04s; --desde: 40px; }
@keyframes tarjeta {
  from { opacity: 0; transform: translateX(var(--desde, 0)) rotateY(35deg) scale(0.85); }
}
#menu.entra .menu-cpu.abierto, #menu.entra .menu-nombres.abierto, #menu.entra .menu-tiempo { animation: aparece 0.6s ease 1.05s both; }
#menu.entra .menu-idioma { animation: aparece 0.6s ease 1.2s both; }
#menu.entra .jugar { animation: jugar-entra 0.9s cubic-bezier(0.2, 1.6, 0.4, 1) 1.15s both, late 1.8s ease-in-out 2.1s infinite; }
#menu.entra .continuar { animation: jugar-entra 0.8s cubic-bezier(0.2, 1.6, 0.4, 1) 0.75s both, late-continuar 1.8s ease-in-out 1.6s infinite; }
#menu.entra .continuar.pulsado { animation: pulsado 0.6s ease-out forwards; }
@keyframes aparece { from { opacity: 0; transform: translateY(14px); } }
@keyframes jugar-entra { from { opacity: 0; transform: scale(0.6); } }
#menu.sale { animation: menu-sale 0.9s cubic-bezier(0.6, 0, 0.8, 0.4) forwards; }
#menu.sale .menu-marca { animation: marca-sale 0.8s cubic-bezier(0.6, 0, 0.8, 0.4) forwards; }
#menu.sale .menu-panel { animation: panel-sale 0.8s cubic-bezier(0.6, 0, 0.8, 0.4) forwards; }
#menu.sale .menu-vineta { animation: desaparece 0.9s ease forwards; }
@keyframes menu-sale { 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes marca-sale { to { transform: translateY(-60px) scale(1.15); filter: blur(8px); opacity: 0; } }
@keyframes panel-sale { to { transform: translateY(80px) scale(0.94); filter: blur(6px); opacity: 0; } }
@keyframes desaparece { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .menu-logo-marco, .menu-logo-marco::after, .menu-marca::before, .modo::before, .jugar, .jugar::before, .continuar, .modo[aria-checked="true"] .modo-icono { animation: none !important; }
}
/* Apaisada y ancha (el ordenador): a dos columnas, el escudo grande a un lado y el panel al otro, como la
   portada de un juego. */
@media (orientation: landscape) and (min-width: 860px) and (min-height: 561px) {
  .menu-caja { flex-direction: row; justify-content: center; gap: clamp(28px, 6vw, 96px); width: min(1180px, 100% - 64px); }
  .menu-marca { flex: 1 1 0; max-width: 540px; }
  .menu-logo-marco { height: min(56vh, 520px); }
  .menu-lema { font-size: 13px; }
  .menu-panel { flex: 0 0 min(470px, 44vw); }
}
/* Apaisada y baja (el móvil tumbado): también a dos columnas, con el escudo más pequeño. */
/* EL MÓVIL. Lo pidió el usuario: el menú tapaba casi toda la pantalla y no se veía el tablero de cine de
   detrás. Más apretado: el escudo pequeño arriba, el panel abajo y, en medio, el tablero. Los modos, en
   pastillas de una línea (icono y nombre) en vez de tarjetas; todo con menos relleno; y el panel, más
   transparente. */
@media (orientation: portrait) and (max-width: 600px) {
  #menu { place-items: stretch; }
  .menu-caja {
    justify-content: space-between;
    gap: 10px;
    width: min(440px, 100% - 24px);
    min-height: 100dvh;
    margin: 0 auto;
    /* Arriba, la barra (el dónut, la cuenta, el trofeo y el idioma): el logo, debajo, sin que lo tape. */
    padding: calc(max(10px, env(safe-area-inset-top)) + 42px) 0 max(12px, env(safe-area-inset-bottom));
  }
  .menu-logo-marco { height: clamp(92px, 15vh, 150px); }
  .menu-marca { gap: 2px; }
  .menu-lema { font-size: 9.5px; letter-spacing: 0.26em; }
  .menu-panel { gap: 9px; padding: 11px 11px 12px; border-radius: 22px; background: linear-gradient(165deg, rgba(24, 28, 46, 0.48), rgba(6, 8, 16, 0.64)); }
  .continuar { gap: 10px; padding: 7px 12px 7px 7px; border-radius: 16px; }
  .continuar-icono { width: 36px; height: 36px; padding: 8px 6px 8px 10px; }
  .continuar-titulo { font-size: 15px; }
  .continuar-sub { font-size: 11px; }
  .menu-modos { gap: 8px; }
  .modo { flex-direction: column; justify-content: center; gap: 4px; padding: 8px 4px; border-radius: 14px; }
  .modo::before { border-radius: 15px; }
  .modo-icono { width: 22px; height: 22px; }
  .modo-titulo { font-size: 13.5px; text-align: center; }
  .modo-sub { display: none; }
  .menu-cpu { gap: 8px; }
  .nombre-campo input { padding: 7px 0; }
  .menu-tiempo { gap: 6px; }
  .tiempo-cat { padding: 7px 2px; }
  .tiempo-op { padding: 7px 4px; font-size: 14px; }
  .nivel-cabecera { margin-bottom: 4px; }
  .nivel-numero { font-size: 26px; }
  .jugar { padding: 13px 20px; font-size: 22px; border-radius: 15px; }
}
/* Tumbado (el móvil girado): a dos columnas, escudo y panel, y si el panel no cabe de alto, se desplaza
   por dentro. Antes, centrado y más alto que la pantalla, se cortaba por arriba sin poder llegar a ello. */
@media (max-height: 560px) and (orientation: landscape) {
  #menu { place-items: stretch; }
  .menu-caja {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: clamp(12px, 4vw, 40px);
    width: 100%;
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  /* El logo se queda con lo que deja el panel (y el lema, si no cabe, se parte en dos líneas). */
  .menu-marca { flex: 1 1 0; min-width: 0; max-width: 420px; }
  .menu-logo-marco { height: min(56vh, 230px); }
  .menu-lema { font-size: 9.5px; letter-spacing: 0.22em; white-space: normal; text-align: center; }
  .menu-lema::before, .menu-lema::after { flex: 0 1 34px; min-width: 10px; }
  .menu-panel {
    flex: 0 0 min(400px, 57vw);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    gap: 8px;
    padding: 10px 12px 12px;
    border-radius: 20px;
    background: linear-gradient(165deg, rgba(24, 28, 46, 0.5), rgba(6, 8, 16, 0.66));
  }
  .continuar { gap: 10px; padding: 6px 12px 6px 6px; border-radius: 14px; }
  .continuar-icono { width: 34px; height: 34px; padding: 8px 6px 8px 10px; }
  .continuar-titulo { font-size: 14px; }
  .continuar-sub { font-size: 10.5px; }
  .menu-modos { gap: 8px; }
  .modo { flex-direction: column; justify-content: center; gap: 3px; padding: 6px 4px; border-radius: 13px; }
  .modo::before { border-radius: 14px; }
  .modo-icono { width: 18px; height: 18px; flex: none; }
  .modo-titulo { font-size: 13px; text-align: center; }
  .modo-sub { display: none; }
  .menu-cpu { gap: 6px; }
  .nombre-campo input { padding: 6px 0; }
  .menu-etiqueta { font-size: 11.5px; }
  .pieza-op { padding: 5px 9px; }
  /* El nivel, en una fila: la etiqueta, su nombre y el número; y debajo, la barra. */
  .menu-nivel { display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 8px; }
  .nivel-cabecera { display: contents; }
  .nivel-cabecera label { grid-area: 1 / 1; font-size: 11.5px; }
  .nivel-nombre { grid-area: 1 / 2; margin: 0; font-size: 13px; }
  .nivel-numero { grid-area: 1 / 3; font-size: 22px; }
  #menu-nivel-rango { grid-area: 2 / 1 / 3 / 4; margin: 5px 0 2px; }
  .menu-tiempo { gap: 5px; }
  .tiempo-cat { padding: 6px 2px; }
  .tiempo-op { padding: 6px 4px; font-size: 13.5px; }
  .jugar { padding: 11px 20px; font-size: 20px; border-radius: 14px; }
  /* La bandera, arriba a la izquierda, sobre el logo (detrás del dónut): a la derecha está el panel. */
  .menu-idioma { top: max(10px, env(safe-area-inset-top)); inset-inline-end: auto; inset-inline-start: calc(max(14px, env(safe-area-inset-left)) + 36px); }
  [dir="rtl"] .menu-idioma { inset-inline-start: max(14px, env(safe-area-inset-right)); } /* allí va a la derecha */
  .idiomas { inset-inline-end: auto; inset-inline-start: 0; max-height: calc(100dvh - 64px); overflow-y: auto; }
}

/* ===== La partida ===== */
.turno {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 10px;
  border: 1px solid rgba(90, 170, 255, 0.45);
  border-radius: 999px;
  background: rgba(6, 12, 28, 0.78);
  box-shadow: 0 0 16px rgba(0, 130, 255, 0.35);
  font: 700 14px/1 system-ui, sans-serif;
  white-space: nowrap;
  transform: translateX(-50%);
}
.turno[hidden] { display: none; }
.turno.cambia { animation: turno-cambia 0.45s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes turno-cambia { from { transform: translateX(-50%) translateY(-12px) scale(0.9); opacity: 0; } }
.turno-pieza { font-size: 20px; line-height: 1; filter: drop-shadow(0 0 4px rgba(120, 200, 255, 0.9)); }
.turno[data-lado="black"] .turno-pieza { color: #222; text-shadow: 0 0 1px #fff, 0 0 6px rgba(255, 255, 255, 0.6); }
.turno.piensa .turno-texto::after { content: '…'; display: inline-block; width: 1.2em; text-align: left; animation: piensa 1.2s steps(4) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes piensa { from { width: 0; } to { width: 1.2em; } }
@media (max-width: 480px) { .turno { top: calc(max(12px, env(safe-area-inset-top)) + 48px); } }
/* Debajo del turno, uno debajo de otro: la conexión online y las tablas ofrecidas. */
.avisos-partida {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + 42px);
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  /* Su ancho, el que pida (con `left: 50%`, sin esto solo cabría en la mitad derecha y se partiría antes). */
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
/* La conexión: ámbar si alguien no tiene red; roja, con los botones de reclamar. */
.conexion, .oferta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 12px;
  border: 1px solid rgba(255, 196, 81, 0.6);
  border-radius: 999px;
  background: rgba(40, 26, 4, 0.85);
  color: #ffe2a8;
  font: 700 13px/1.2 system-ui, sans-serif;
  pointer-events: auto;
}
.conexion[hidden], .oferta[hidden] { display: none; }
/* Las tablas: azules, como el turno; con botones, la caja se redondea para caber en dos líneas. */
.oferta { flex-wrap: wrap; border-color: rgba(90, 170, 255, 0.6); border-radius: 16px; background: rgba(6, 14, 34, 0.9); color: #d6ebff; }
.oferta .conexion-boton.principal { background: linear-gradient(180deg, #9fd2ff, #3b8fe0); color: #021428; }
.oferta-texto { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conexion[data-estado="reclamable"] { flex-wrap: wrap; border-color: rgba(255, 90, 70, 0.75); border-radius: 16px; background: rgba(48, 8, 6, 0.9); color: #ffd0c8; }
.conexion-texto { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conexion-botones { display: inline-flex; gap: 8px; }
.conexion-botones[hidden] { display: none; }
.conexion-boton { padding: 6px 12px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; background: rgba(255, 255, 255, 0.08); color: inherit; font: 800 12.5px/1 system-ui, sans-serif; cursor: pointer; }
.conexion-boton.principal { border: 0; background: linear-gradient(180deg, #ff9a8a, #e0402c); color: #2a0400; }
.conexion-boton[hidden] { display: none; }
@media (max-width: 480px) { .avisos-partida { top: calc(max(12px, env(safe-area-inset-top)) + 90px); } }

.cartel {
  position: fixed;
  left: 50%;
  top: 40%;
  z-index: 60;
  font: 900 clamp(46px, 13vw, 96px)/1 Impact, "Arial Black", system-ui, sans-serif;
  letter-spacing: 0.06em;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.4);
  white-space: nowrap;
}
/* Una frase que no cabe en una línea (`banner`): en dos, equilibradas, dentro de la pantalla (con el golpe de entrada). */
.cartel.largo { width: max-content; max-width: calc((100vw - 32px) / 1.15); line-height: 1.08; text-align: center; white-space: normal; text-wrap: balance; }
.cartel[data-tipo="jaque"] { color: #ffe0d8; text-shadow: 0 0 10px #ff2a2a, 0 0 28px #ff2a2a, 0 0 60px #ff0040, 3px 3px 0 #6a0000; }
.cartel[data-tipo="tablas"] { color: #e0f2ff; text-shadow: 0 0 10px #2a9dff, 0 0 28px #2a7dff, 0 0 60px #4040ff, 3px 3px 0 #001a4a; }
.cartel.sale { animation: cartel 1.5s cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
@keyframes cartel {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(-3deg); }
  30% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1.04) rotate(-3deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3) rotate(-3deg); }
}

.final, .corona {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 45%, rgba(0, 20, 60, 0.55), rgba(0, 0, 0, 0.78));
}
.final[hidden], .corona[hidden] { display: none; }
/* Con la escena del jaque mate detrás: el cartel abajo y un velo ligero, que se vea al rey de rodillas y la fiesta. */
.final.con-escena {
  place-items: end center;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.55));
}
.final-caja, .corona-caja {
  position: relative;
  width: min(380px, 100%);
  padding: 26px 22px 22px;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(22, 32, 64, 0.97), rgba(6, 8, 18, 0.98));
  text-align: center;
  box-shadow: 0 0 40px rgba(0, 120, 255, 0.4);
}
.final-caja::before, .corona-caja::before {
  content: '';
  position: absolute;
  inset: -2px;
  padding: 2px;
  border-radius: 21px;
  background: conic-gradient(from var(--giro), #00d2ff, #0050ff, #7a3cff, #ff3cac, #00d2ff);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: giro 3s linear infinite;
  pointer-events: none;
}
.final.entra .final-caja { animation: final-entra 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes final-entra { from { opacity: 0; transform: scale(0.6) translateY(30px); } }
.final-titulo { margin: 0 0 8px; font: 900 34px/1.05 system-ui, sans-serif; letter-spacing: 0.02em; }
.final[data-tipo="gana"] .final-titulo { color: #ffd66b; text-shadow: 0 0 18px rgba(255, 190, 60, 0.8); }
.final[data-tipo="pierde"] .final-titulo { color: #ff8a7a; text-shadow: 0 0 18px rgba(255, 60, 60, 0.7); }
.final[data-tipo="tablas"] .final-titulo { color: #9fd8ff; text-shadow: 0 0 18px rgba(60, 160, 255, 0.7); }
.final-texto { margin: 0 0 20px; opacity: 0.85; }
/* La puntuación que cambia al acabar. */
.final-puntos { display: flex; flex-direction: column; gap: 6px; margin: -8px 0 18px; }
.final-puntos:empty { display: none; }
.final-punto { display: grid; grid-template-columns: 1fr auto auto; align-items: baseline; gap: 10px; padding: 7px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); text-align: start; }
.final-punto-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; opacity: 0.8; }
.final-punto-cifra { font: 900 22px/1 system-ui, sans-serif; color: #fff; font-variant-numeric: tabular-nums; }
.final-punto-delta { min-width: 46px; font: 800 15px/1 system-ui, sans-serif; text-align: end; font-variant-numeric: tabular-nums; }
.final-punto-delta.sube { color: #6be08a; }
.final-punto-delta.baja { color: #ff8a7a; }
.final-punto-delta.igual { color: #c9d4ee; }
/* Provisional: la palabra junto al nombre, y debajo, qué quiere decir. */
.final-punto-prov { display: inline-block; margin-inline-start: 8px; padding: 2px 7px; border-radius: 999px; background: rgba(255, 196, 81, 0.18); color: #ffd66b; font: 800 11px/1.2 system-ui, sans-serif; vertical-align: 2px; }
/* En el móvil, si no cabe al lado del nombre, la etiqueta baja (antes se cortaba: «provi…»). */
.final-punto-nombre:has(.final-punto-prov) { white-space: normal; }
@media (max-width: 480px) { .final-punto-prov { display: block; width: max-content; margin: 3px 0 0; } }
.final-punto-nota { margin: 0 4px; font-size: 12px; line-height: 1.35; opacity: 0.75; }
/* El resumen de la partida. */
.final-resumen { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: -6px 0 18px; }
.final-resumen:empty { display: none; }
.final-dato { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); }
.final-dato strong { font: 900 17px/1 system-ui, sans-serif; color: #fff; font-variant-numeric: tabular-nums; }
.final-dato span { font-size: 11px; opacity: 0.7; }
.final-botones { display: flex; gap: 10px; justify-content: center; }
.final-boton, .ajustes-accion {
  padding: 12px 22px;
  border: 1px solid rgba(120, 190, 255, 0.5);
  border-radius: 999px;
  background: rgba(10, 20, 45, 0.9);
  color: #dcecff;
  font: 700 15px/1 system-ui, sans-serif;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1), box-shadow 0.2s;
}
.final-boton:hover, .ajustes-accion:hover { transform: scale(1.05); box-shadow: 0 0 16px rgba(0, 140, 255, 0.6); }
.final-boton.principal { border: 0; background: linear-gradient(180deg, #fff1bf, #f8c451 40%, #e08a1c); color: #2a1400; box-shadow: 0 0 20px rgba(255, 160, 30, 0.5); }
.corona-titulo { margin: 0 0 14px; font: 900 26px/1 system-ui, sans-serif; color: #ffd66b; text-shadow: 0 0 14px rgba(255, 190, 60, 0.7); }
.corona-botones { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.corona-boton {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 2px;
  border: 1px solid rgba(120, 190, 255, 0.4);
  border-radius: 14px;
  background: rgba(10, 20, 45, 0.9);
  color: #e8f2ff;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1), box-shadow 0.2s;
}
.corona-boton:hover, .corona-boton:focus-visible { transform: translateY(-3px) scale(1.06); box-shadow: 0 0 18px rgba(0, 150, 255, 0.7); }
.corona-simbolo { font-size: 34px; line-height: 1; }
.corona[data-lado="black"] .corona-simbolo { color: #111; text-shadow: 0 0 1px #fff, 0 0 8px rgba(255, 255, 255, 0.7); }
.corona-nombre { font-size: 12px; opacity: 0.8; }

.ajustes-partida { margin: 0 0 12px; opacity: 0.85; }

/* ===== El reloj de ajedrez ===== */
.reloj {
  position: absolute;
  left: 50%;
  bottom: max(44px, calc(env(safe-area-inset-bottom) + 34px));
  transform: translateX(-50%);
  direction: ltr;
  pointer-events: none;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.85));
}
.reloj[hidden] { display: none; }
.reloj-caja {
  position: relative;
  width: min(330px, 86vw);
  padding: 22px 12px 10px;
  border-radius: 14px 14px 10px 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 38%),
    linear-gradient(180deg, #2a2a2e, #0c0c0e 60%, #050506);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 6px rgba(0, 0, 0, 0.8),
    0 0 0 1px #000,
    0 0 0 2.5px rgba(212, 170, 80, 0.75),
    0 0 18px rgba(255, 190, 80, 0.12);
}
.reloj-frente { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.reloj-cara {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 52px;
  padding: 6px 8px;
  border-radius: 7px;
  background: radial-gradient(120% 140% at 50% 0%, #1b1407, #080603 70%);
  box-shadow: inset 0 2px 7px rgba(0, 0, 0, 0.95), inset 0 0 0 1px rgba(255, 180, 60, 0.12), 0 1px 0 rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.reloj-cara::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.1), transparent 45%);
  pointer-events: none;
}
.reloj-pieza { font-size: 17px; line-height: 1; opacity: 0.55; color: #f4ead7; transition: opacity 0.3s; }
.reloj-cara[data-lado="black"] .reloj-pieza { color: #111; text-shadow: 0 0 1px #d8c9a8; }
.reloj-cifras { flex: 1; height: 100%; display: flex; align-items: center; justify-content: flex-end; }
.reloj-cifras svg { height: 100%; width: 100%; overflow: visible; }
.reloj-cifras rect { transition: fill 0.25s, opacity 0.25s; }
.reloj-cifras .off { fill: #ffb547; opacity: 0.07; }
.reloj-cifras .on { fill: #ffb547; opacity: 0.5; }
.reloj-cara.activa .reloj-cifras .on { opacity: 1; filter: drop-shadow(0 0 2px rgba(255, 181, 71, 0.9)); }
.reloj-cara.activa .reloj-pieza { opacity: 1; }
.reloj-cara.activa { box-shadow: inset 0 2px 7px rgba(0, 0, 0, 0.95), inset 0 0 0 1px rgba(255, 180, 60, 0.35), 0 0 14px rgba(255, 170, 50, 0.25); }
.reloj-cara.apurado .reloj-cifras .on { fill: #ff4d3d; filter: drop-shadow(0 0 3px rgba(255, 60, 40, 0.95)); }
.reloj-cara.apurado .reloj-cifras .off { fill: #ff4d3d; }
.reloj-cara.apurado .dos-puntos { animation: parpadea 1s steps(2) infinite; }
.reloj-cara.agotado .reloj-cifras .on { fill: #ff2a1a; opacity: 1; }
@keyframes parpadea { 50% { opacity: 0.15; } }
.reloj.en-pausa .reloj-cara.activa .dos-puntos { animation: parpadea 1.2s steps(2) infinite; }
.reloj-marca {
  display: flex;
  flex-direction: column;
  align-items: center;
  font: 800 7.5px/1.2 system-ui, sans-serif;
  letter-spacing: 0.24em;
  color: #d4aa50;
  text-shadow: 0 1px 0 #000;
  opacity: 0.85;
}
/* Quién juega con cada color, debajo de su cara: el nombre y la puntuación. */
.reloj-jugadores { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; padding: 0 4px; }
.reloj-jugadores[hidden] { display: none; }
.reloj-jugadores span { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 11px/1.2 system-ui, sans-serif; color: #f0e2c0; text-align: center; }
.reloj[data-corre="white"] .reloj-jugadores span[data-lado="white"], .reloj[data-corre="black"] .reloj-jugadores span[data-lado="black"] { color: #ffe08a; }
.reloj-ritmo {
  margin-top: 7px;
  text-align: center;
  font: 700 10px/1 system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(212, 170, 80, 0.85);
}

/* Los pulsadores: arriba el del bando al que le corre el tiempo; hundido, el otro. */
.pulsador {
  position: absolute;
  top: -15px;
  width: 30%;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #4b4b52, #1b1b1f);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 3px rgba(0, 0, 0, 0.7), 0 0 0 1px #000;
  cursor: pointer;
  pointer-events: auto;
  transform: translateY(9px) scaleY(0.72);
  transform-origin: 50% 100%;
  transition: transform 0.16s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.2s, filter 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.pulsador[data-lado="white"] { left: 12%; }
.pulsador[data-lado="black"] { right: 12%; }
/* Su luz, un LED (lo pidió el usuario): naranja cuando su reloj está parado, verde cuando corre. Con su brillo de
   cristal arriba y el halo de la luz alrededor. */
.pulsador span {
  position: absolute;
  inset: 5px 12% auto;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(180deg, #ffe0bd 0%, #ff9a3d 38%, #e8650d 70%, #9e3a00 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.65), 0 0 6px rgba(255, 128, 32, 0.55), inset 0 -1px 2px rgba(80, 20, 0, 0.6);
  transition: background 0.25s, box-shadow 0.25s;
}
.pulsador span::after {
  content: '';
  position: absolute;
  inset: 1px 18% auto;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.65);
}
.reloj[data-corre="white"] .pulsador[data-lado="white"] span,
.reloj[data-corre="black"] .pulsador[data-lado="black"] span {
  background: linear-gradient(180deg, #e2ffec 0%, #5cf29a 38%, #18c25e 70%, #076b33 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.65), 0 0 10px rgba(40, 230, 120, 0.85), 0 0 22px rgba(40, 230, 120, 0.35), inset 0 -1px 2px rgba(0, 50, 20, 0.6);
}
/* En pausa (una jugada animándose, un combate), la verde respira despacio. */
.reloj.en-pausa[data-corre="white"] .pulsador[data-lado="white"] span,
.reloj.en-pausa[data-corre="black"] .pulsador[data-lado="black"] span { animation: led-pausa 1.4s ease-in-out infinite; }
@keyframes led-pausa { 50% { filter: brightness(0.6); } }
.reloj[data-corre="white"] .pulsador[data-lado="white"],
.reloj[data-corre="black"] .pulsador[data-lado="black"] { transform: none; }
.reloj[data-espera="white"] .pulsador[data-lado="white"],
.reloj[data-espera="black"] .pulsador[data-lado="black"] { animation: llama 1.1s ease-in-out infinite; }
@keyframes llama {
  0%, 100% { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 3px rgba(0, 0, 0, 0.7), 0 0 0 1px #000, 0 0 6px rgba(0, 255, 110, 0.35); }
  50% { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 3px rgba(0, 0, 0, 0.7), 0 0 0 1px #000, 0 0 20px rgba(0, 255, 110, 0.95); }
}
.pulsador.golpe { animation: golpe 0.28s cubic-bezier(0.3, 1.8, 0.5, 1); }
@keyframes golpe {
  0% { transform: none; filter: brightness(1.8); }
  40% { transform: translateY(12px) scaleY(0.6); }
  100% { transform: translateY(9px) scaleY(0.72); }
}
.pulsador.niega { animation: niega 0.3s ease; }
@keyframes niega { 25% { transform: translateY(9px) scaleY(0.72) translateX(-3px); } 75% { transform: translateY(9px) scaleY(0.72) translateX(3px); } }
@media (max-width: 480px) { .reloj-cara { height: 44px; } }
.turno.pulsa { border-color: rgba(0, 255, 110, 0.7); box-shadow: 0 0 18px rgba(0, 255, 110, 0.45); animation: turno-pulsa 1.1s ease-in-out infinite; }
@keyframes turno-pulsa { 50% { box-shadow: 0 0 30px rgba(0, 255, 110, 0.75); } }

/* ===== Buscando rival online ===== */
.online {
  position: fixed;
  inset: 0;
  z-index: 790;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 45%, rgba(0, 20, 60, 0.35), rgba(0, 0, 0, 0.7));
}
.online[hidden] { display: none; }
.online-caja {
  position: relative;
  width: min(360px, 100%);
  padding: 24px 22px 22px;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(22, 32, 64, 0.95), rgba(6, 8, 18, 0.97));
  text-align: center;
  box-shadow: 0 0 40px rgba(0, 120, 255, 0.4);
  animation: final-entra 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.online-radar { position: relative; width: 96px; height: 96px; margin: 0 auto 14px; display: grid; place-items: center; }
.online-radar svg { width: 54px; height: 54px; fill: none; stroke: #9fd8ff; stroke-width: 2.2; stroke-linecap: round; filter: drop-shadow(0 0 8px rgba(60, 160, 255, 0.8)); animation: online-gira 9s linear infinite; }
.online-radar span {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(90, 180, 255, 0.7);
  border-radius: 50%;
  animation: online-onda 2.4s ease-out infinite;
}
.online-radar span:nth-child(2) { animation-delay: 0.8s; }
.online-radar span:nth-child(3) { animation-delay: 1.6s; }
.online.encontrado .online-radar span { border-color: rgba(255, 200, 80, 0.85); }
.online.encontrado .online-radar svg { stroke: #ffd66b; filter: drop-shadow(0 0 10px rgba(255, 180, 40, 0.9)); }
@keyframes online-onda { from { transform: scale(0.45); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
@keyframes online-gira { to { transform: rotate(360deg); } }
.online-titulo { margin: 0 0 6px; font: 900 24px/1.1 system-ui, sans-serif; color: #dcecff; text-shadow: 0 0 14px rgba(0, 140, 255, 0.6); }
.online.encontrado .online-titulo { color: #ffd66b; text-shadow: 0 0 16px rgba(255, 190, 60, 0.8); }
.online-texto { min-height: 2.6em; margin: 0 0 18px; opacity: 0.85; }
.online[data-fase="error"] .online-radar span { animation: none; opacity: 0; }
.online[data-fase="error"] .online-radar svg { stroke: #ff8a7a; animation: none; }
@media (prefers-reduced-motion: reduce) {
  .online-radar span, .online-radar svg { animation: none !important; }
}

/* ===== La sala: quién hay online ===== */
/* La píldora, en la esquina de la tarjeta «Online»: cuántos hay; verde y latiendo si alguno está libre. */
.modo-sala {
  position: absolute;
  top: -10px;
  inset-inline-end: -6px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px 4px 7px;
  border: 1px solid rgba(150, 200, 255, 0.45);
  border-radius: 999px;
  background: rgba(8, 14, 30, 0.94);
  color: #bfd9f5;
  font: 800 12px/1 system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.modo-sala:hover { transform: scale(1.1); }
.modo-sala svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.modo-sala.hay {
  border-color: #45f08a;
  color: #d4ffe3;
  background: rgba(6, 30, 18, 0.95);
  animation: sala-late 1.6s ease-in-out infinite;
}
@keyframes sala-late {
  0%, 100% { box-shadow: 0 0 8px rgba(40, 240, 130, 0.45), 0 2px 10px rgba(0, 0, 0, 0.5); transform: scale(1); }
  50% { box-shadow: 0 0 20px rgba(40, 240, 130, 0.95), 0 2px 10px rgba(0, 0, 0, 0.5); transform: scale(1.07); }
}
.modo[data-modo="online"]::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.modo[data-modo="online"].hay-gente::after {
  opacity: 1;
  box-shadow: 0 0 0 1.5px rgba(60, 240, 140, 0.8), 0 0 22px rgba(40, 240, 130, 0.55);
  animation: gente-late 1.6s ease-in-out infinite;
}
.modo[data-modo="online"].hay-gente .modo-icono { color: #6dffa8; filter: drop-shadow(0 0 6px rgba(40, 240, 130, 0.8)); }
@keyframes gente-late { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* La sala, encima del menú. */
.sala {
  position: fixed;
  inset: 0;
  z-index: 970;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background: radial-gradient(circle at 50% 40%, rgba(0, 20, 50, 0.45), rgba(0, 0, 0, 0.78));
}
.sala[hidden] { display: none; }
.sala-caja {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(420px, 100%);
  max-height: min(640px, 100%);
  padding: 18px 16px 16px;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(22, 30, 58, 0.97), rgba(6, 8, 18, 0.98));
  box-shadow: 0 0 0 1px rgba(255, 214, 140, 0.25), 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 36px rgba(0, 120, 255, 0.25);
  color: #eef3ff;
}
.sala.entra .sala-caja { animation: final-entra 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.sala-cabecera { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sala-titulo { margin: 0; font: 900 21px/1.1 system-ui, sans-serif; color: #ffd66b; text-shadow: 0 0 12px rgba(255, 190, 60, 0.5); }
/* Cómo va mi conexión con la sala: un punto junto al título (verde, con red; ámbar, sin ella). */
.sala-punto { display: inline-block; width: 9px; height: 9px; margin-inline-start: 8px; border-radius: 50%; background: #3be38a; box-shadow: 0 0 8px rgba(59, 227, 138, 0.8); vertical-align: middle; }
.sala-punto.sin-red { background: #ffc451; box-shadow: 0 0 8px rgba(255, 196, 81, 0.8); animation: gente-late 1.2s ease-in-out infinite; }
.sala-cerrar { width: 34px; height: 34px; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50%; background: rgba(255, 255, 255, 0.06); color: #dfe8ff; font-size: 16px; cursor: pointer; }
.sala-yo { margin: -4px 0 0; font-size: 13px; opacity: 0.75; }
.sala-buscar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid rgba(255, 214, 140, 0.22);
  border-radius: 999px;
  background: rgba(8, 10, 20, 0.75);
}
.sala-buscar:focus-within { border-color: #ffc451; box-shadow: 0 0 12px rgba(255, 160, 40, 0.4); }
.sala-buscar svg { width: 18px; height: 18px; flex: none; fill: none; stroke: #e9dcc0; stroke-width: 2; stroke-linecap: round; opacity: 0.8; }
.sala-buscar input { flex: 1; min-width: 0; padding: 9px 0; border: 0; background: transparent; color: #fff; font: 600 16px/1.2 system-ui, sans-serif; outline: none; }
.sala-buscar input::placeholder { color: rgba(233, 220, 192, 0.5); }
.sala-lista { display: flex; flex-direction: column; gap: 6px; min-height: 60px; margin: 0; padding: 2px; overflow-y: auto; list-style: none; }
.sala-jugador {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  animation: aparece 0.3s ease both;
}
.sala-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, hsl(var(--tono), 70%, 55%), hsl(var(--tono), 70%, 32%));
  color: #fff;
  font: 900 17px/1 system-ui, sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.sala-avatar::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border: 2px solid #0b1124;
  border-radius: 50%;
  background: #45f08a;
}
.sala-jugador[data-estado="seeking"] .sala-avatar::after { background: #ffc451; animation: sala-punto 1s ease-in-out infinite; }
.sala-jugador[data-estado="playing"] .sala-avatar::after { background: #8a93a8; }
@keyframes sala-punto { 50% { transform: scale(1.35); } }
.sala-datos { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.sala-nombre { font: 700 15px/1.2 system-ui, sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sala-estado { font-size: 12px; opacity: 0.7; }
.sala-jugador[data-estado="seeking"] .sala-estado { color: #ffd66b; opacity: 0.95; }
.sala-retar {
  flex: none;
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff1bf, #f8c451 40%, #e08a1c);
  color: #2a1400;
  font: 800 13px/1 system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 160, 30, 0.35);
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.sala-retar:hover:not(:disabled) { transform: scale(1.06); }
.sala-retar:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.sala-retar.esperando { background: rgba(255, 196, 81, 0.15); color: #ffd66b; box-shadow: inset 0 0 0 1px #ffc451; animation: gente-late 1.2s ease-in-out infinite; }
.sala-vacia { margin: 6px 0; text-align: center; font-size: 14px; opacity: 0.75; }

/* Los retos que llegan: arriba, encima de todo (también del dónut, que está en la esquina). */
.retos {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  z-index: 2147482100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100% - 24px));
  transform: translateX(-50%);
  pointer-events: none;
}
.reto {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 12px 12px;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(165deg, rgba(40, 24, 8, 0.97), rgba(12, 8, 4, 0.98));
  box-shadow: 0 0 0 1px #ffc451, 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 26px rgba(255, 170, 40, 0.45);
  color: #fff3dc;
  pointer-events: auto;
  animation: reto-entra 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.reto.sale { animation: reto-sale 0.3s ease forwards; }
@keyframes reto-entra { from { opacity: 0; transform: translateY(-30px) scale(0.9); } }
@keyframes reto-sale { to { opacity: 0; transform: translateY(-20px) scale(0.95); } }
.reto-icono { flex: none; font-size: 24px; filter: drop-shadow(0 0 6px rgba(255, 190, 60, 0.9)); animation: icono 1.2s ease-in-out infinite; }
.reto-textos { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.reto-textos b { font: 800 15px/1.2 system-ui, sans-serif; color: #ffd66b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reto-textos span { font-size: 12.5px; opacity: 0.85; }
.reto-si, .reto-no { flex: none; padding: 9px 12px; border-radius: 999px; font: 800 13px/1 system-ui, sans-serif; cursor: pointer; }
.reto-si { border: 0; background: linear-gradient(180deg, #c9ffd9, #45f08a 45%, #14a352); color: #04230f; box-shadow: 0 0 12px rgba(40, 240, 130, 0.5); }
.reto-no { border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.06); color: #f3e6d0; }
.reto-tiempo { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: linear-gradient(90deg, #ffc451, #ff6b3d); transform-origin: left; animation: reto-cuenta var(--dura, 60s) linear forwards; }
@keyframes reto-cuenta { to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .modo-sala.hay, .modo[data-modo="online"].hay-gente::after, .reto-icono, .sala-retar.esperando { animation: none !important; }
}

/* Tus partidas, arriba de la sala. */
.sala-seccion { display: flex; flex-direction: column; gap: 6px; }
.sala-seccion[hidden] { display: none; }
.sala-subtitulo { margin: 4px 0 0; font: 800 12px/1 system-ui, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; }
.sala-partidas { max-height: 34vh; }
.sala-partida { display: flex; align-items: center; gap: 6px; animation: aparece 0.3s ease both; }
.sala-partida-boton {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.sala-partida-boton:disabled { cursor: default; }
.sala-partida[data-estado="toca"] .sala-partida-boton { border-color: #ffc451; box-shadow: 0 0 14px rgba(255, 170, 40, 0.35); }
.sala-partida[data-estado="aqui"] .sala-partida-boton { border-color: rgba(90, 180, 255, 0.6); }
.sala-chip { flex: none; padding: 5px 9px; border-radius: 999px; font: 800 11.5px/1 system-ui, sans-serif; background: rgba(255, 255, 255, 0.1); color: #dfe8ff; }
.sala-partida[data-estado="toca"] .sala-chip { background: #ffc451; color: #2a1400; animation: gente-late 1.2s ease-in-out infinite; }
.sala-partida[data-estado="aqui"] .sala-chip { background: rgba(90, 180, 255, 0.25); color: #bfe3ff; }
.sala-partida[data-estado="ganada"] .sala-chip { background: rgba(40, 240, 130, 0.25); color: #b9ffd5; }
.sala-partida[data-estado="perdida"] .sala-chip { background: rgba(255, 90, 70, 0.25); color: #ffc2b8; }
.sala-partida[data-estado="desconectado"] .sala-chip { background: rgba(255, 196, 81, 0.22); color: #ffe2a8; }
.sala-quitar { flex: none; width: 30px; height: 30px; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50%; background: rgba(255, 255, 255, 0.06); color: #dfe8ff; cursor: pointer; }
/* Los avisos de tus partidas (no son retos): azules. */
.reto.aviso { background: linear-gradient(165deg, rgba(10, 24, 50, 0.97), rgba(4, 8, 18, 0.98)); box-shadow: 0 0 0 1px rgba(90, 180, 255, 0.8), 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 22px rgba(0, 130, 255, 0.4); }
.reto.aviso .reto-textos b { color: #dcecff; white-space: normal; }
.reto.aviso .reto-tiempo { background: linear-gradient(90deg, #37b6ff, #7a3cff); }
.sala-partida .sala-avatar::after { display: none; } /* el punto de estado es de los jugadores, no de las partidas */

/* EL RANKING: el botón del menú (trofeo y puntuación, junto al idioma) y su panel. */
.menu-idioma { display: flex; align-items: center; gap: 8px; }
.ranking-boton {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px 0 9px;
  border: 1px solid rgba(255, 214, 140, 0.35);
  border-radius: 999px;
  background: rgba(8, 10, 20, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #ffd66b;
  font: 800 14px/1 system-ui, sans-serif;
  cursor: pointer;
}
.ranking-boton svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ranking-boton:hover { border-color: #ffc451; box-shadow: 0 0 12px rgba(255, 160, 40, 0.4); }
.ranking-caja { width: min(560px, 100%); max-height: min(720px, 100%); overflow: hidden; }
.rk-intro { margin: -4px 0 0; font-size: 13px; line-height: 1.4; opacity: 0.75; }
.rk-cuerpo { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.rk-tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.rk-carta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 0 0 1px rgba(255, 214, 140, 0.16);
}
.rk-cabeza { display: flex; align-items: center; gap: 6px; font: 700 13px/1.2 system-ui, sans-serif; color: #e9dcc0; }
.rk-cabeza svg { width: 17px; height: 17px; fill: none; stroke: #ffc451; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rk-puntos { font: 900 30px/1.05 system-ui, sans-serif; color: #fff; letter-spacing: 0.01em; }
.rk-prov { margin-inline-start: 2px; font-size: 20px; color: #ffc451; opacity: 0.85; cursor: help; }
.rk-datos { font-size: 11.5px; line-height: 1.35; opacity: 0.7; }
.rk-mejor { font-size: 11.5px; color: #ffd66b; opacity: 0.85; }
.rk-grafica { width: 100%; height: 30px; margin-top: 2px; }
.rk-grafica polyline { fill: none; stroke: #6fb6ff; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.rk-seccion { display: flex; flex-direction: column; gap: 6px; }
.rk-subtitulo { margin: 0; font: 800 12px/1.2 system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: #ffd66b; opacity: 0.9; }
.rk-vacio { margin: 0; font-size: 13px; opacity: 0.65; }
.rk-tabla { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.rk-fila { display: grid; grid-template-columns: 28px 1fr auto auto; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); font-size: 14px; }
.rk-fila:first-child .rk-pos { color: #ffd66b; }
.rk-fila.yo { box-shadow: inset 0 0 0 1px rgba(255, 196, 81, 0.6); background: rgba(255, 196, 81, 0.1); }
.rk-pos { font-weight: 900; opacity: 0.8; text-align: end; }
.rk-quien { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.rk-r { font-weight: 900; color: #fff; }
.rk-n { font-size: 12px; opacity: 0.6; }
.rk-pestanas { display: flex; flex-wrap: wrap; gap: 6px; }
.rk-pestana { padding: 5px 11px; border: 1px solid rgba(255, 214, 140, 0.25); border-radius: 999px; background: transparent; color: #e9dcc0; font: 700 12px/1 system-ui, sans-serif; cursor: pointer; }
.rk-pestana.activa { border-color: #ffc451; background: rgba(255, 196, 81, 0.16); color: #ffd66b; }
.rk-cuenta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 14px; background: rgba(0, 120, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(90, 170, 255, 0.3); }
.rk-cuenta[hidden] { display: none; }
#menu.entra .menu-idioma .ranking-boton { animation: aparece 0.6s ease 1.2s both; }
/* La cuenta, junto al trofeo: su inicial y su nombre; sin cuenta, la persona, «Invitado · Entrar». */
.cuenta-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  max-width: 44vw;
  padding: 0 12px 0 4px;
  border: 1px solid rgba(255, 214, 140, 0.35);
  border-radius: 999px;
  background: rgba(8, 10, 20, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #e9dcc0;
  font: 700 13.5px/1 system-ui, sans-serif;
  cursor: pointer;
}
.cuenta-chip[hidden] { display: none; }
.cuenta-chip:hover { border-color: #ffc451; box-shadow: 0 0 12px rgba(255, 160, 40, 0.4); }
.cuenta-chip-ico { display: grid; flex: none; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); font: 900 13px/1 system-ui, sans-serif; }
.cuenta-chip-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cuenta-chip.dentro .cuenta-chip-ico { background: linear-gradient(160deg, #6fb6ff, #2f6fe0); color: #fff; }
.cuenta-chip.sin-confirmar .cuenta-chip-ico { box-shadow: 0 0 0 2px #ffc451; } /* falta confirmar el correo */
.cuenta-chip-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cuenta-chip:not(.dentro) .cuenta-chip-nombre { opacity: 0.75; }
.cuenta-chip-entrar { color: #ffd66b; font-weight: 900; white-space: nowrap; }
.cuenta-chip-entrar::before { content: '·'; margin-inline-end: 7px; color: #e9dcc0; opacity: 0.6; font-weight: 700; }
.cuenta-chip-entrar[hidden] { display: none; }
#menu.entra .menu-idioma .cuenta-chip { animation: aparece 0.6s ease 1.2s both; }
/* En los móviles más estrechos, sin cuenta, solo «Entrar». */
@media (max-width: 380px) {
  .cuenta-chip:not(.dentro) .cuenta-chip-nombre, .cuenta-chip-entrar::before { display: none; }
}

/* EL NIVEL DE SALIDA (`ui/nivel-ui.js`): cuatro botones grandes, cada uno con su puntuación. */
.sala.nivel { z-index: 985; }
.nivel-caja { width: min(400px, 100%); gap: 12px; }
.nivel-intro { margin: -4px 0 0; font-size: 13.5px; line-height: 1.4; opacity: 0.8; }
.nivel-opciones { display: grid; gap: 8px; }
.nivel-op {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 10px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 214, 140, 0.3);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  color: #f4ead7;
  text-align: start;
  cursor: pointer;
}
.nivel-op:hover, .nivel-op:focus-visible { border-color: #ffc451; box-shadow: 0 0 14px rgba(255, 160, 40, 0.35); outline: none; }
.nivel-op b { font: 800 16px/1.2 system-ui, sans-serif; }
.nivel-cifra { font: 900 20px/1 system-ui, sans-serif; color: #ffd66b; font-variant-numeric: tabular-nums; }
.nivel-sub { grid-column: 1 / -1; font-size: 12.5px; opacity: 0.7; }

/* LA CUENTA: su zona en el panel del ranking y la ventana de entrar (encima del ranking). */
.sala.cuenta { z-index: 980; }
.cuenta-caja { width: min(380px, 100%); gap: 12px; }
.cuenta-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px 16px; border: 0; border-radius: 999px; background: #fff; color: #1f1f1f; font: 700 16px/1 system-ui, sans-serif; cursor: pointer; }
.cuenta-google svg { width: 20px; height: 20px; flex: none; }
.cuenta-google:disabled, .cuenta-enviar:disabled { opacity: 0.6; cursor: default; }
.cuenta-o { display: flex; align-items: center; gap: 10px; font-size: 12px; opacity: 0.6; }
.cuenta-o::before, .cuenta-o::after { content: ''; flex: 1; height: 1px; background: rgba(255, 255, 255, 0.2); }
.cuenta-form { display: flex; flex-direction: column; gap: 8px; }
.cuenta-campo { padding: 11px 14px; border: 1px solid rgba(255, 214, 140, 0.25); border-radius: 12px; background: rgba(8, 10, 20, 0.75); color: #fff; font: 600 16px/1.2 system-ui, sans-serif; outline: none; }
.cuenta-campo:focus { border-color: #ffc451; box-shadow: 0 0 12px rgba(255, 160, 40, 0.35); }
.cuenta-campo::placeholder { color: rgba(233, 220, 192, 0.5); }
.cuenta-campo[hidden] { display: none; }
.cuenta-enviar { width: 100%; margin-top: 4px; }
.cuenta-enlace { align-self: center; padding: 4px; border: 0; background: none; color: #9fd0ff; font: 600 13px/1.3 system-ui, sans-serif; text-decoration: underline; cursor: pointer; }
.cuenta-enlace[hidden] { display: none; }
.cuenta-mensaje { min-height: 1.3em; margin: 0; font-size: 13px; text-align: center; color: #ffd66b; }
.cuenta-porque { margin: -4px 0 0; font-size: 13px; line-height: 1.4; opacity: 0.75; }
/* El nombre del ranking, comprobado al escribirlo: libre en verde, cogido en rojo. */
.cuenta-nombre-estado { min-height: 1.2em; margin: -4px 4px 0; font-size: 12.5px; line-height: 1.3; opacity: 0.85; }
.cuenta-nombre-estado:empty { min-height: 0; margin: 0; }
.cuenta-nombre-estado[hidden] { display: none; }
.cuenta-nombre-estado[data-estado="libre"] { color: #6be08a; }
.cuenta-nombre-estado[data-estado="cogido"] { color: #ff8a7a; }
.cuenta-ranking { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-top: 2px; font-size: 13px; }
.cuenta-ranking .cuenta-enlace { padding: 0 2px; }
.cuenta-ranking.cambiando { flex-direction: column; align-items: stretch; width: 100%; }
.cuenta-ranking.cambiando .cuenta-boton { align-self: flex-start; }
/* Seguir sin cuenta: tan a mano como entrar. */
.cuenta-invitado { width: 100%; padding: 11px 16px; border: 1px solid rgba(255, 214, 140, 0.3); border-radius: 999px; background: rgba(255, 255, 255, 0.04); color: #e9dcc0; font: 700 15px/1 system-ui, sans-serif; cursor: pointer; }
.cuenta-invitado:hover { border-color: #ffc451; }
.cuenta-inicial { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(180deg, #fff1bf, #f8c451 45%, #e08a1c); color: #2a1400; font: 900 18px/1 system-ui, sans-serif; }
.cuenta-textos { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cuenta-quien { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.cuenta-texto { flex: 1; margin: 0; font-size: 13px; line-height: 1.35; opacity: 0.8; }
.cuenta-boton { padding: 8px 14px; border: 0; border-radius: 999px; background: linear-gradient(180deg, #fff1bf, #f8c451 40%, #e08a1c); color: #2a1400; font: 800 13px/1 system-ui, sans-serif; cursor: pointer; }
.cuenta-boton.secundario { background: rgba(255, 255, 255, 0.08); color: #dfe8ff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
.cuenta-acciones { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.cuenta-alerta { align-self: center; font-size: 12px; color: #ffd66b; }

/* Invitar a un amigo (la sala): un enlace que, al abrirlo, le reta directamente. */
.sala-invitar { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; }
.sala-invitar svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Las últimas partidas (el panel del ranking): icono del ritmo, rival, resultado, puntos y cuándo. */
.rk-ultimas { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.rk-partida { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 46px auto; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); font-size: 14px; }
.rk-partida svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.75; }
.rk-p-quien { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-p-quien small { opacity: 0.6; font-size: 12px; }
.rk-p-res { padding: 2px 8px; border-radius: 999px; font: 700 11px/1.4 system-ui, sans-serif; letter-spacing: 0.03em; text-transform: uppercase; background: rgba(255, 255, 255, 0.08); }
.rk-partida.w .rk-p-res { background: rgba(70, 200, 120, 0.2); color: #8ff0b3; }
.rk-partida.l .rk-p-res { background: rgba(240, 90, 80, 0.2); color: #ffaca4; }
.rk-p-delta { font: 700 14px/1 system-ui, sans-serif; text-align: right; font-variant-numeric: tabular-nums; }
.rk-partida.w .rk-p-delta { color: #8ff0b3; }
.rk-partida.l .rk-p-delta { color: #ffaca4; }
.rk-p-cuando { font-size: 12px; opacity: 0.6; white-space: nowrap; }
.rk-puesto { margin: 6px 0 8px; font: 700 15px/1.3 system-ui, sans-serif; color: #ffd66b; }
