/* ===========================================================================
   La Plaza — estilos
   Dos pantallas: acceso (lobby) y mundo (plaza). El mundo es un canvas a pantalla
   completa; todo lo demás flota encima.
   =========================================================================== */

:root {
  --bg: #10141c;
  --bg-soft: #181e2a;
  --bg-card: #1c2331;
  --line: #2b3547;
  --text: #e8ecf4;
  --text-dim: #94a0b8;
  --accent: #4a9eff;
  --accent-soft: #8fe3ff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { overflow: hidden; }

.screen { position: fixed; inset: 0; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ lobby -- */

.lobby {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(1100px 600px at 50% -10%, #23324a 0%, transparent 60%),
    var(--bg);
}

.lobby__card {
  width: min(880px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 30px;
}

.lobby__head h1 {
  margin: 0 0 6px;
  font-size: 30px;
  letter-spacing: -0.5px;
}

.lobby__head p {
  margin: 0 0 24px;
  color: var(--text-dim);
  max-width: 56ch;
}

.lobby__grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  align-items: start;
}

@media (max-width: 720px) {
  .lobby__grid { grid-template-columns: 1fr; }
  .lobby__card { padding: 22px; }
}

.lobby__foot {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-dim);
}

.lobby__foot a { color: var(--accent); text-decoration: none; }
.lobby__foot a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- preview -- */

.preview { display: grid; gap: 10px; }

.preview__stage {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0d1117;
  border: 1px solid var(--line);
}

.preview__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Espejado: la cámara frontal se ve invertida y todo el mundo espera verse
     como en un espejo. */
  transform: scaleX(-1);
}

.preview__idle {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 6px;
  background: rgba(16, 20, 28, 0.72);
  color: var(--text-dim);
  font-size: 13px;
  padding: 16px;
}

.preview__icon { font-size: 30px; }
.preview__idle p { margin: 0; }

/* ------------------------------------------------------------------ forms -- */

.form { display: grid; gap: 16px; }

.field {
  display: grid;
  gap: 6px;
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0;
}

.field__hint { font-size: 12px; color: var(--text-dim); }

.field__input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
}

.field__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.colors { display: flex; flex-wrap: wrap; gap: 9px; }

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease;
}

.swatch:hover { transform: scale(1.08); }

.swatch[aria-checked="true"] {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.45);
}

.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------- voz (lobby) -- */

.voice-setup {
  grid-column: 1 / -1;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.check {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.check b { display: block; font-size: 14px; }
.check small { display: block; color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }

.voice-setup__warn {
  margin: 0;
  padding: 9px 12px;
  border-radius: 9px;
  background: #43350f;
  color: #fde68a;
  font-size: 12.5px;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- botones -- */

.btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.btn--primary { background: var(--accent); color: #08131f; }

.btn--ghost {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
}

.msg { margin: 0; font-size: 13px; min-height: 1.2em; color: var(--text-dim); }
.msg--bad { color: var(--bad); }
.msg--ok { color: var(--ok); }
.msg--warn { color: var(--warn); }

/* ------------------------------------------------------------- roles (lobby) */

.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

@media (max-width: 560px) {
  .roles { grid-template-columns: 1fr; }
}

.role { cursor: pointer; }
.role input { position: absolute; opacity: 0; pointer-events: none; }

.role__body {
  display: block;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.role__body b { display: block; font-size: 14px; margin-bottom: 3px; }
.role__body small { display: block; color: var(--text-dim); font-size: 12px; line-height: 1.45; }

.role input:checked + .role__body {
  border-color: var(--accent);
  background: #1b3350;
}

.role input:focus-visible + .role__body { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- galería -- */

.gallery {
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 700px at 50% 0%, #1e2a3d 0%, var(--bg) 65%);
  padding: 14px 16px 16px;
  gap: 12px;
}

.gallery__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.gallery__title h1 { margin: 0; font-size: 19px; }
.gallery__title p { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }
.gallery__tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* Escenario principal: el expositor. Ocupa todo el alto disponible. */
.gallery__stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}

/* Tira inferior con el resto de los participantes. */
.gallery__strip {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

/* Sin expositor presente, la tira pasa a ser una rejilla que ocupa todo. */
.gallery--grid .gallery__stage { display: none; }

.gallery--grid .gallery__strip {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  overflow-y: auto;
  align-content: start;
}

.tile {
  position: relative;
  flex-shrink: 0;
  width: 168px;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: #0d1117;
  border: 1px solid var(--line);
}

.gallery--grid .tile { width: auto; }

/* El tile del expositor es el protagonista. 16:9 porque es la proporción en la que
   se captura su cámara: con 4:3 sobraba marco y la imagen salía recortada. */
.tile--host {
  width: auto;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  border-color: rgba(143, 227, 255, 0.4);
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.5);
}

/* El video del expositor se muestra COMPLETO, sin recortar.
   `cover` llena el marco a costa de cortar los bordes, y con una cara centrada eso
   se ve como si estuviera pegada al lente. `contain` respeta el encuadre real de su
   cámara, que es el que esa persona eligió al sentarse frente a ella. */
.tile--host .tile__media {
  object-fit: contain;
  background: #05070a;
}

.tile__media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #0d1117;
}

/* El canvas de los recortes se amplía; suavizarlo evita el aspecto pixelado. */
canvas.tile__media { image-rendering: auto; }

.tile__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 10px;
}

.tile__empty span { font-size: 26px; }

.tile__bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: linear-gradient(transparent, rgba(8, 11, 16, 0.9));
  font-size: 12.5px;
  font-weight: 500;
}

.tile__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile__badge {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(143, 227, 255, 0.2);
  color: var(--accent-soft);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tile__mic { flex-shrink: 0; margin-left: auto; font-size: 12px; }

/* Anillo cuando alguien habla: la señal más útil en una videollamada. */
.tile--talking { border-color: #4ade80; }
.tile--talking::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px #4ade80;
  pointer-events: none;
}

.gallery__foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.gallery__hint { margin: 0; color: var(--text-dim); font-size: 13px; }

.btn--big { padding: 14px 26px; font-size: 15px; }

/* -------------------------------------------------------------- confeti ---- */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 70;      /* por encima de la cortina, para verlo al descubrirse */
  pointer-events: none;
  width: 100%;
  height: 100%;
}

/* ------------------------------------------------------------- transición -- */

.curtain {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: #070a0f;
  animation: curtainIn 0.5s ease forwards;
}

.curtain--out { animation: curtainOut 0.75s ease forwards; }

.curtain__inner { text-align: center; padding: 24px; }

.curtain__text {
  margin: 0;
  font-size: clamp(22px, 5vw, 40px);
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #eaf6ff;
  animation: curtainText 1.2s ease forwards;
}

@keyframes curtainIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes curtainOut {
  from { opacity: 1; }
  to { opacity: 0; visibility: hidden; }
}

@keyframes curtainText {
  0% { opacity: 0; transform: scale(0.94); }
  35% { opacity: 1; transform: scale(1); }
  100% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .curtain, .curtain--out, .curtain__text { animation-duration: 0.01ms; }
}

/* ------------------------------------------------------------------ plaza -- */

.plaza { background: #10141c; }

.plaza__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* -------------------------------------------------------------------- hud -- */

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  pointer-events: none;
}

.hud__left, .hud__right { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  pointer-events: auto;
  background: rgba(16, 20, 28, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.chip--action { cursor: pointer; font: inherit; font-size: 13px; }
.chip--action:hover { background: rgba(40, 52, 72, 0.9); }
.chip--action:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.chip--ok { color: var(--ok); }
.chip--warn { color: var(--warn); }
.chip--bad { color: var(--bad); }

/* Controles exclusivos del expositor: se distinguen para que no se confundan con
   los del resto del HUD, y para que él los encuentre de inmediato. */
.chip--host {
  background: #3a2758;
  border-color: #6d4aa8;
  color: #d9c2ff;
  font-weight: 600;
}

.chip--host:hover { background: #4a3170; }

/* El micrófono abierto tiene que ser inconfundible: transmitir sin darse cuenta
   es el peor error posible en una herramienta así. */
.chip--mic[aria-pressed="true"] {
  background: #1d4d33;
  border-color: #2f7f52;
  color: #86efac;
}

.chip--mic[aria-pressed="true"]::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse 1.6s ease-in-out infinite;
  vertical-align: middle;
}

.chip[aria-pressed="true"]:not(.chip--mic) {
  background: #4a3a12;
  border-color: #78591a;
  color: #fde68a;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .chip--mic[aria-pressed="true"]::before { animation: none; }
}

/* --------------------------------------------------------------- acciones -- */

.actions {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.actions__group {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.act {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(16, 20, 28, 0.82);
  backdrop-filter: blur(8px);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.act:hover { background: rgba(44, 58, 80, 0.92); }
.act:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.act__icon { font-size: 16px; line-height: 1; }

.act[aria-pressed="true"] {
  background: #1d3a5c;
  border-color: var(--accent);
  color: var(--accent-soft);
}

/* Las contextuales se distinguen: aparecen y desaparecen según dónde estés, y
   conviene que se lean como algo distinto de las acciones siempre disponibles. */
.act--context {
  background: rgba(30, 44, 26, 0.88);
  border-color: rgba(140, 220, 120, 0.35);
}

.act--context:hover { background: rgba(44, 66, 38, 0.94); }

.act--waiting {
  background: rgba(74, 58, 18, 0.9);
  border-color: #a8801e;
  color: #fde68a;
}

@media (max-width: 620px) {
  /* En pantalla angosta las etiquetas no caben junto al chat: quedan los íconos,
     que con el title siguen siendo descubribles. */
  .act__label { display: none; }
  .act { padding: 10px 12px; }
}

/* ------------------------------------------------------------------ stats -- */

.stats {
  position: absolute;
  top: 58px;
  right: 14px;
  width: 260px;
  background: rgba(16, 20, 28, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
}

.stats h2 { margin: 0 0 10px; font-size: 14px; }

.stats dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
}

.stats dt { color: var(--text-dim); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.stats__note {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
}

/* ------------------------------------------------------------------- chat -- */

.badge {
  display: inline-block;
  min-width: 17px;
  padding: 0 5px;
  margin-left: 3px;
  border-radius: 9px;
  background: var(--accent);
  color: #08131f;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 17px;
}

.chat {
  position: absolute;
  bottom: 14px;
  left: 14px;
  width: min(330px, calc(100% - 28px));
  max-height: min(58vh, 460px);
  display: flex;
  flex-direction: column;
  background: rgba(16, 20, 28, 0.93);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat__title {
  margin: 0;
  padding: 11px 14px 8px;
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
}

.chat__log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 80px;
}

.chat__row { display: grid; gap: 2px; }

.chat__meta {
  display: flex;
  gap: 7px;
  align-items: baseline;
  font-size: 11.5px;
}

.chat__who { font-weight: 600; color: var(--accent-soft); }
.chat__row--self .chat__who { color: var(--ok); }
.chat__when { color: #6b7689; font-size: 10.5px; }

.chat__text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  /* Un mensaje con una palabra larguísima no debe ensanchar el panel. */
  overflow-wrap: anywhere;
}

/* Mensaje propio aún sin confirmar por el servidor. */
.chat__row--pending { opacity: 0.55; }

.chat__form {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  border-top: 1px solid var(--line);
}

.chat__input {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}

.chat__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat__counter {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: right;
}

.chat__counter--low { color: var(--warn); font-weight: 600; }

.chat__send {
  border: 0;
  border-radius: 9px;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: var(--accent);
  color: #08131f;
  font-size: 14px;
  cursor: pointer;
}

.chat__send:hover { filter: brightness(1.12); }
.chat__send:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

/* En pantallas bajas el chat competiría con la vista propia de la cámara. */
@media (max-height: 560px) {
  .chat { max-height: 46vh; }
}

/* ------------------------------------------------------------------- mapa -- */

.map {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 11, 16, 0.82);
  backdrop-filter: blur(6px);
}

.map__box {
  width: min(1000px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.map__head h2 { margin: 0; font-size: 16px; }

.map__close {
  border: 0;
  background: var(--bg-soft);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.map__close:hover { background: #2c3648; }
.map__close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.map__canvas {
  width: 100%;
  /* La plaza mide 2400×1400: la misma proporción evita deformar el plano. */
  aspect-ratio: 12 / 7;
  display: block;
  background: #2a3a28;
  cursor: crosshair;
  min-height: 0;
}

.map__legend {
  margin: 0;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12.5px;
}

/* -------------------------------------------------------------- vestuario -- */

.map__box--narrow { width: min(560px, 100%); }

.wardrobe {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 18px;
  padding: 16px;
  align-items: start;
}

@media (max-width: 540px) {
  .wardrobe { grid-template-columns: 1fr; justify-items: center; }
}

.wardrobe__preview {
  width: 200px;
  height: 260px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #6d9b5c, #c9bda6 72%);
  border: 1px solid var(--line);
}

.wardrobe__options { display: grid; gap: 8px; min-width: 0; }

.wardrobe__label {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
}

.wardrobe__label + * { margin-bottom: 6px; }

.hats { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 7px; }

.hat {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.hat:hover { background: #26303f; }
.hat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hat__icon { font-size: 20px; line-height: 1; }
.hat__label { font-size: 10.5px; color: var(--text-dim); text-align: center; line-height: 1.25; }

.hat--on {
  border-color: var(--accent);
  background: #1b3350;
}

.hat--on .hat__label { color: var(--accent-soft); }

/* ------------------------------------------- piedra, papel o tijera -------- */

.rps {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  width: min(340px, calc(100% - 28px));
  background: rgba(16, 20, 28, 0.93);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 15px 15px;
  z-index: 15;
}

.rps__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.rps__head h2 { margin: 0; font-size: 14px; }

.rps__leave {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 5px 10px;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.rps__leave:hover { color: var(--text); background: #2c3648; }

.rps__score {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.rps__board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.rps__side { display: grid; justify-items: center; gap: 5px; flex: 1; min-width: 0; }

/* --- Tarjetas que se voltean -------------------------------------------------
   El volteo es una rotación 3D real: las dos caras existen a la vez y se oculta la
   que queda de espaldas. Cambiar el contenido de un solo elemento no daría la
   sensación de dar vuelta una carta. */

.card {
  width: 66px;
  height: 88px;
  perspective: 600px;
  transition: transform 0.25s ease;
}

.card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.35, 1.4, 0.5, 1);
}

.card--flipped .card__inner { transform: rotateY(180deg); }

.card__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 2px solid var(--line);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Dorso: se ve mientras la jugada es secreta. */
.card__back {
  background:
    repeating-linear-gradient(45deg, #253044 0 6px, #1d2636 6px 12px);
  color: #6b7689;
  font-size: 26px;
  font-weight: 700;
}

.card__front {
  background: #f6f8fa;
  font-size: 34px;
  transform: rotateY(180deg);
}

.card--empty { opacity: 0.4; }
.card--empty .card__back { font-size: 22px; }

/* Ya eligió, pero no se sabe qué: el borde lo delata sin revelar nada. */
.card--ready .card__back {
  border-color: var(--warn);
  color: var(--warn);
}

.card--win { transform: translateY(-6px) scale(1.08); }
.card--win .card__front { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.35); }
.card--lose .card__front { opacity: 0.55; }

/* --- Plazo ------------------------------------------------------------------ */

.rps__timer {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
  margin: 0 0 10px;
}

.rps__timer-bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 999px;
}

/* Para quien aún no eligió, el plazo es urgente. */
.rps__timer--urgent .rps__timer-bar { background: var(--bad); }

/* --- Tarjetas para elegir --------------------------------------------------- */

.pick {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 10px 4px;
  border-radius: 11px;
  border: 2px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.pick:hover:not(:disabled) {
  background: #26303f;
  transform: translateY(-3px);
}

.pick:disabled { opacity: 0.35; cursor: not-allowed; }
.pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick__icon { font-size: 26px; line-height: 1; }
.pick__label { color: var(--text-dim); }

.pick--chosen {
  border-color: var(--accent);
  background: #1b3350;
  opacity: 1;
}

.pick--chosen .pick__label { color: var(--accent-soft); }

.rps__player {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rps__vs { font-size: 11px; color: #6b7689; flex-shrink: 0; }

.rps__moves { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }

.rps__status {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  text-align: center;
  min-height: 1.2em;
}

/* ------------------------------------------------------- hint y banner ---- */

.hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(16, 20, 28, 0.75);
  color: var(--text-dim);
  font-size: 13px;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.hint--gone { opacity: 0; }

.banner {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 28px));
  padding: 12px 18px;
  border-radius: var(--radius);
  background: #4c1d1d;
  color: #fecaca;
  border: 1px solid #7f2d2d;
  box-shadow: var(--shadow);
  font-size: 14px;
  text-align: center;
}

.banner--warn { background: #43350f; color: #fde68a; border-color: #78591a; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
