/* =========================================================================
   Fiesta — hoja de estilos única. Mobile-first, oscura, pensada para verse
   a un metro de distancia en el sofá y con el móvil pasando de mano en mano.
   ========================================================================= */

:root {
  --bg: #0a0710;
  --bg-2: #140c1e;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.11);
  --line-soft: rgba(255, 255, 255, 0.06);
  --text: #f6f1f9;
  --muted: #a294b1;
  --hot: #ff2f7b;
  --flame: #ff8a3d;
  --night: #7b6bff;
  --mint: #2fe3a8;
  --danger: #ff5a5a;

  --grad-fuego: linear-gradient(135deg, #ff2f7b 0%, #ff8a3d 100%);
  --grad-noche: linear-gradient(135deg, #7b6bff 0%, #37d0ff 100%);

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-full: 999px;

  --pad: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html { background: var(--bg); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}

/* Fondo con dos manchas de color que se mueven muy despacio. */
.glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60vw 60vw at 15% -5%, rgba(255, 47, 123, 0.28), transparent 62%),
    radial-gradient(55vw 55vw at 95% 8%, rgba(123, 107, 255, 0.26), transparent 60%),
    radial-gradient(70vw 50vw at 50% 108%, rgba(255, 138, 61, 0.14), transparent 65%),
    var(--bg);
  animation: drift 24s var(--ease) infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(0, -3%, 0) scale(1.08); }
}

/* ------------------------------------------------------------- estructura */

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 18px) var(--pad) calc(var(--safe-b) + 28px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: screen-in 0.34s var(--ease) both;
}

.screen[hidden] { display: none; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ marca */

.home { display: flex; flex-direction: column; gap: 22px; }

.brand { text-align: center; padding: 26px 0 4px; }

.brand-name {
  margin: 0;
  /* "Los Pikaos" es largo: el tope baja para que no parta en dos líneas. */
  font-size: clamp(34px, 12.5vw, 54px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.92;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--grad-fuego);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Pegado justo debajo del nombre, blanco y mucho más pequeño. */
.brand-game {
  margin: 2px 0 0;
  font-size: clamp(13px, 4.4vw, 19px);
  font-weight: 800;
  letter-spacing: 0.46em;
  text-indent: 0.46em;
  text-transform: uppercase;
  color: #fff;
}

.brand-sub {
  margin: 12px auto 0;
  max-width: 26ch;
  color: var(--muted);
  font-size: 15px;
}

/* ----------------------------------------------------------------- piezas */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.stack { display: flex; flex-direction: column; gap: 12px; }

.field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-label.mt { margin-top: 18px; }

.input {
  width: 100%;
  padding: 15px 16px;
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input::placeholder { color: #6d6178; }
.input:focus {
  border-color: rgba(255, 47, 123, 0.7);
  box-shadow: 0 0 0 4px rgba(255, 47, 123, 0.16);
}

.input-code {
  text-align: center;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-transform: uppercase;
  padding: 16px 12px;
  margin-bottom: 12px;
}

/* ------------------------------------------------------------------ caras */

/* Un avatar es un emoji o una foto; ocupan lo mismo para que nada baile. */
.avatar {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  line-height: 1;
  border-radius: 50%;
  overflow: hidden;
}
.avatar.is-photo { object-fit: cover; background: rgba(255, 255, 255, 0.08); }

.avatar-sm { width: 22px; height: 22px; font-size: 18px; }
.avatar-md { width: 30px; height: 30px; font-size: 26px; }
.avatar-lg { width: 100%; height: 100%; font-size: 24px; }

/* Los emojis no necesitan recorte redondo; las fotos sí. */
.avatar:not(.is-photo) { border-radius: 0; overflow: visible; }

.avatar-grid {
  display: grid;
  gap: 5px;
}
.avatar-grid.is-emoji { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.avatar-grid.is-photo { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }

.avatar-opt {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.16s var(--ease), border-color 0.16s, background 0.16s;
}
.avatar-grid.is-photo .avatar-opt { border-radius: 50%; }
.avatar-opt:active { transform: scale(0.9); }
.avatar-opt[aria-checked="true"] {
  border-color: var(--hot);
  background: rgba(255, 47, 123, 0.18);
  transform: scale(1.06);
}
.avatar-grid.is-photo .avatar-opt[aria-checked="true"] {
  box-shadow: 0 0 0 3px rgba(255, 47, 123, 0.28);
}

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

.btn {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  background: var(--surface-2);
  border-radius: var(--r-full);
  padding: 15px 22px;
  cursor: pointer;
  transition: transform 0.14s var(--ease), opacity 0.2s, box-shadow 0.2s, background 0.2s;
  touch-action: manipulation;
  user-select: none;
}
.btn:active { transform: scale(0.965); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.btn-xl { padding: 19px 24px; font-size: 18px; letter-spacing: -0.01em; }

/* Compacto, para que icono y texto quepan en una línea sin apreturas. */
.btn-sm {
  padding: 12px 14px;
  font-size: 14.5px;
  gap: 7px;
  white-space: nowrap;
}

.btn .icon { flex: 0 0 auto; opacity: 0.9; }

.btn-primary {
  background: var(--grad-fuego);
  color: #fff;
  box-shadow: 0 10px 30px -10px rgba(255, 47, 123, 0.85);
}

.btn-night {
  background: var(--grad-noche);
  color: #fff;
  box-shadow: 0 10px 30px -10px rgba(123, 107, 255, 0.85);
}

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--line);
}

.btn-quiet {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
  padding: 12px 16px;
}
.btn-quiet:hover { color: var(--text); }

.btn-danger { background: rgba(255, 90, 90, 0.16); color: #ff8f8f; }

.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

.foot {
  text-align: center;
  color: #6d6178;
  font-size: 12.5px;
  margin: 4px 0 0;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.topbar-actions .btn-quiet { padding: 10px 4px 10px 8px; white-space: nowrap; }

.code-card {
  text-align: center;
  padding: 22px 18px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.code-label {
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.code-value {
  font-size: clamp(52px, 19vw, 76px);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  line-height: 1.05;
  margin: 6px 0 14px;
  background: var(--grad-fuego);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.players {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}

.player {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  animation: pop 0.3s var(--ease) both;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.86); }
  to   { opacity: 1; transform: none; }
}

.player .avatar-md { width: 42px; height: 42px; font-size: 28px; }
.player-name {
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player.is-off { opacity: 0.38; }
.player.is-me { border-color: rgba(255, 47, 123, 0.55); }

.player-tag {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--grad-fuego);
  color: #fff;
  white-space: nowrap;
}

.player-kick {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

/* --------------------------------------------------------- selector juegos */

.games { display: flex; flex-direction: column; gap: 12px; }

.game-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.16s var(--ease), border-color 0.2s;
}
.game-card:active { transform: scale(0.98); }
.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.14;
  transition: opacity 0.2s;
}
.game-card.accent-fuego::before { background: var(--grad-fuego); }
.game-card.accent-noche::before { background: var(--grad-noche); }
.game-card:not(.is-locked):hover::before { opacity: 0.24; }

.game-card.is-locked { opacity: 0.55; cursor: default; }

/* La ilustración del juego, en el hueco del emoji. */
.game-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 13px;
  object-fit: cover;
  display: block;
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.9);
}

.game-emoji { font-size: 32px; position: relative; flex: 0 0 auto; }
.game-body { position: relative; flex: 1; min-width: 0; display: block; }
.game-name { display: block; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.game-tag { display: block; font-size: 13.5px; color: var(--muted); margin-top: 3px; text-wrap: pretty; }

.pill {
  position: relative;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  white-space: nowrap;
}

.waiting {
  text-align: center;
  padding: 30px 18px;
  color: var(--muted);
}
.waiting .dots span {
  display: inline-block;
  width: 8px; height: 8px;
  margin: 0 3px;
  border-radius: 50%;
  background: var(--hot);
  animation: bounce 1.2s infinite var(--ease);
}
.waiting .dots span:nth-child(2) { animation-delay: 0.15s; }
.waiting .dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-9px); opacity: 1; }
}

/* --------------------------------------------------------------- yo nunca */

.game-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.q-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.q-card {
  /* Llena el hueco libre y encoge cuando debajo aparecen los resultados. */
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 190px;
  padding: 30px 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(160deg, rgba(255, 47, 123, 0.16), rgba(123, 107, 255, 0.1)),
    var(--surface);
  box-shadow: 0 24px 60px -30px rgba(255, 47, 123, 0.7);
}

/* En la pantalla final manda el podio, así que la carta no se estira. */
.q-card.is-end { flex: 0 0 auto; min-height: 0; padding: 26px 22px; }

.q-card.flip { animation: flip-in 0.42s var(--ease) both; }
@keyframes flip-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96) rotate(-1.2deg); }
  to   { opacity: 1; transform: none; }
}

.q-kicker {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--hot);
  margin-bottom: 12px;
}

.q-text {
  font-size: clamp(23px, 6.6vw, 31px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.18;
  margin: 0;
  text-wrap: balance;
}

/* Sin margin-top:auto: los márgenes automáticos se comen el espacio libre
   antes de que la carta pueda crecer, y la carta se queda encogida. */
.vote-row { display: flex; gap: 12px; }
.vote {
  flex: 1;
  padding: 20px 12px;
  border-radius: var(--r-lg);
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s var(--ease), border-color 0.2s, background 0.2s;
}
.vote:active { transform: scale(0.96); }
.vote .vote-emoji { display: block; font-size: 26px; margin-bottom: 4px; }
.vote.pick-si.is-on { border-color: var(--hot); background: rgba(255, 47, 123, 0.2); }
.vote.pick-no.is-on { border-color: var(--mint); background: rgba(47, 227, 168, 0.16); }
.vote:disabled { opacity: 0.45; cursor: default; }

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}
.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--grad-fuego);
  transition: width 0.35s var(--ease);
}

.reveal { display: flex; flex-direction: column; gap: 10px; }

.reveal-head {
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  color: var(--muted);
}
.reveal-head b { color: var(--hot); font-size: 19px; }

.reveal-list { display: flex; flex-direction: column; gap: 7px; }

.reveal-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--surface);
  animation: slide-in 0.32s var(--ease) both;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: none; }
}
.reveal-row.said-si { border-color: rgba(255, 47, 123, 0.5); background: rgba(255, 47, 123, 0.12); }
.reveal-row .avatar-md { width: 26px; height: 26px; font-size: 21px; }
.reveal-row .r-name { flex: 1; font-weight: 700; font-size: 15px; }
.reveal-row .r-verdict { font-size: 12.5px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; }
.reveal-row.said-si .r-verdict { color: var(--hot); }
.reveal-row.said-no .r-verdict { color: var(--muted); }
.reveal-row.said-nada .r-verdict { color: #5d5268; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 700;
}
.chip.is-done { border-color: rgba(47, 227, 168, 0.5); background: rgba(47, 227, 168, 0.12); }

/* --------------------------------------------------------------- podio fin */

.podium { display: flex; flex-direction: column; gap: 8px; }
.podium-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-soft);
}
.podium-row:first-child {
  border-color: rgba(255, 138, 61, 0.6);
  background: linear-gradient(90deg, rgba(255, 138, 61, 0.18), transparent);
}
.podium-pos { font-size: 18px; width: 26px; text-align: center; }
.podium-name { flex: 1; font-weight: 700; }
.podium-count { font-weight: 900; color: var(--flame); }

/* ---------------------------------------------------------------- niveles */

.levels { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.level-opt {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 16px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s var(--ease), border-color 0.2s, background 0.2s;
}
.level-opt:active { transform: scale(0.98); }
.level-opt[aria-checked="true"] {
  border-color: var(--hot);
  background: rgba(255, 47, 123, 0.15);
}
.level-emoji { font-size: 25px; flex: 0 0 auto; }
.level-body { min-width: 0; }
.level-name { display: block; font-weight: 800; font-size: 16px; }
.level-desc { display: block; font-size: 13px; color: var(--muted); text-wrap: pretty; }

/* -------------------------------------------------------- estado conexión */

.conn {
  position: fixed;
  top: calc(var(--safe-t) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 7px 15px;
  border-radius: var(--r-full);
  background: rgba(255, 90, 90, 0.9);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.8);
  animation: pop 0.25s var(--ease) both;
}
.conn[hidden] { display: none; }

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--safe-b) + 14px);
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}

.toast {
  max-width: 100%;
  padding: 11px 18px;
  border-radius: var(--r-full);
  background: rgba(24, 16, 34, 0.95);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: toast-in 0.3s var(--ease) both;
}
.toast.tone-error { border-color: rgba(255, 90, 90, 0.6); color: #ffb3b3; }
.toast.leaving { animation: toast-out 0.25s var(--ease) both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(0.96); }
}

/* ------------------------------------------------------------ accesibilidad */

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