:root {
  --primary: #46178f;
  --primary-light: #7c4fe0;
  --accent: #26890c;
  --accent2: #e21b3c;
  --accent3: #1368ce;
  --accent4: #ffa602;
  --bg: #f7f4fb;
  --card-bg: #ffffff;
  --text: #2b1f3d;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(70, 23, 143, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background: #1a0f36;
}

/* Fondo animado tipo "lámpara de lava": blobs de color que flotan y cambian de tono. */
.lava-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(160deg, #1a0f36 0%, #2d1155 50%, #0f1f4d 100%);
}
.lava-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.55;
  mix-blend-mode: screen;
  animation: lavaFloat 26s ease-in-out infinite, lavaHue 18s linear infinite;
}
.lava-blob:nth-child(1) { width: 420px; height: 420px; left: -10%; top: 10%; background: #ff2fb0; animation-duration: 22s, 16s; }
.lava-blob:nth-child(2) { width: 360px; height: 360px; right: -8%; top: 30%; background: #7c4fe0; animation-duration: 30s, 20s; animation-delay: -4s, -2s; }
.lava-blob:nth-child(3) { width: 300px; height: 300px; left: 20%; bottom: -10%; background: #1368ce; animation-duration: 24s, 22s; animation-delay: -8s, -6s; }
.lava-blob:nth-child(4) { width: 340px; height: 340px; right: 15%; bottom: -12%; background: #ffa602; animation-duration: 34s, 24s; animation-delay: -12s, -3s; }
.lava-blob:nth-child(5) { width: 260px; height: 260px; left: 45%; top: -8%; background: #26890c; animation-duration: 28s, 26s; animation-delay: -6s, -10s; }

@keyframes lavaFloat {
  0%   { transform: translate(0, 0) scale(1); }
  25%  { transform: translate(40px, 60px) scale(1.15); }
  50%  { transform: translate(-30px, 30px) scale(0.9); }
  75%  { transform: translate(30px, -40px) scale(1.05); }
  100% { transform: translate(0, 0) scale(1); }
}
@keyframes lavaHue {
  0%   { filter: blur(50px) hue-rotate(0deg); }
  100% { filter: blur(50px) hue-rotate(360deg); }
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.screen {
  display: none;
  animation: fadeIn 0.25s ease;
}
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand {
  text-align: center;
  color: white;
  margin: 30px 0 20px;
}
.brand .logo { font-size: 64px; }

/* Logo tipo "cuadros unidos" (puzzle blocks) para Next Tap Puzzle / Fast Tap Play */
.logo-blocks {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 8px;
}
.logo-blocks .block {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 900;
  color: white;
  box-shadow: 0 6px 16px rgba(0,0,0,0.3), inset 0 -4px 0 rgba(0,0,0,0.15);
  transform: rotate(0deg);
  animation: blockPop 0.5s ease backwards;
}
.logo-blocks .block:nth-child(1) { animation-delay: 0s; }
.logo-blocks .block:nth-child(2) { animation-delay: 0.1s; }
.logo-blocks .block:nth-child(3) { animation-delay: 0.2s; }
.logo-blocks .b-f { background: var(--accent2); transform: rotate(-6deg); }
.logo-blocks .b-t { background: var(--accent4); color: #402800; }
.logo-blocks .b-p { background: var(--accent3); transform: rotate(6deg); }

@keyframes blockPop {
  from { opacity: 0; transform: scale(0.4) rotate(0deg); }
  to   { opacity: 1; }
}
.brand h1 {
  font-size: 3rem;
  margin: 4px 0;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.brand .tagline { opacity: 0.9; font-size: 1.1rem; }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 600px) {
  .menu-grid { grid-template-columns: 1fr; }
}

.btn-card {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius);
  padding: 22px 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(70,23,143,0.25); }
.btn-card .icon { font-size: 2.2rem; }
.btn-card .title { font-size: 1.2rem; font-weight: 800; color: var(--primary); }
.btn-card .desc { color: #6b6178; font-size: 0.9rem; }

.btn-back {
  background: rgba(255,255,255,0.15);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 30px;
  cursor: pointer;
  margin-bottom: 14px;
  font-weight: 600;
}
.btn-back:hover { background: rgba(255,255,255,0.28); }

h2 { color: white; text-shadow: 0 2px 8px rgba(0,0,0,0.25); }

.config-form {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.config-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
}
.config-form input[type=text],
.config-form input[type=number],
.config-form select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid #e3dcf0;
  font-size: 1rem;
}
.switch-row {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
}
.switch-row input { width: 20px; height: 20px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.chip {
  background: #efe8fb;
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  border: 2px solid transparent;
  user-select: none;
}
.chip.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary-light);
}

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
}
.avatar-picker img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  background: #eee;
  object-fit: cover;
}
.avatar-picker img.selected {
  border-color: var(--accent4);
  box-shadow: 0 0 0 3px rgba(255,166,2,0.35);
}

.btn-primary, .btn-secondary, .btn-danger {
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: #e6e0f2; color: var(--primary); }
.btn-danger { background: var(--accent2); color: white; }
.btn-primary:hover, .btn-secondary:hover, .btn-danger:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.room-code {
  background: var(--accent4);
  color: #402800;
  padding: 4px 14px;
  border-radius: 10px;
  letter-spacing: 3px;
  font-family: monospace;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 16px 0;
}
@media (max-width: 640px) {
  .lobby-grid { grid-template-columns: 1fr; }
}
.lobby-qr-box, .lobby-players {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
.lobby-qr-box img { width: 220px; height: 220px; border-radius: 12px; }
.hint { color: #766c85; font-size: 0.9rem; }

.lobby-players h3, .lobby-players ul { text-align: left; }
.lobby-players ul { list-style: none; padding: 0; margin: 10px 0; }
.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4f0fb;
  margin-bottom: 6px;
}
.player-item img { width: 32px; height: 32px; border-radius: 50%; }
.player-item .badge-host {
  background: var(--accent4);
  color: #402800;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 800;
}
.player-item.dead { opacity: 0.45; text-decoration: line-through; }
.player-item .name { flex: 1; font-weight: 700; }
.player-item .score { font-weight: 800; color: var(--primary); }

#lobby-teams-box { text-align: left; margin-top: 14px; }
.team-block {
  border: 2px solid #e3dcf0;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}
.team-block h4 { margin: 0 0 6px; color: var(--primary); }
.team-block button { margin-top: 6px; }

.hidden { display: none !important; }

.game-top {
  display: flex;
  justify-content: space-between;
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 10px;
}
.game-timer { background: var(--accent2); padding: 4px 14px; border-radius: 20px; }
.mode-badges { display: flex; gap: 6px; }
.mode-badge {
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
}

.chain-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.chain-label { color: #766c85; font-weight: 700; text-transform: uppercase; font-size: 0.8rem; }
.chain-word {
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--primary);
  margin: 6px 0;
  word-break: break-word;
}
.chain-hint { color: #4a3d63; font-weight: 600; }
.chain-hint span { color: var(--accent2); font-weight: 900; font-size: 1.2rem; }
.chain-translation {
  color: #7a5cff;
  font-weight: 700;
  font-size: 1.1rem;
  font-style: italic;
  margin-bottom: 6px;
}

/* PvP 1v1 simultáneo: dos carriles lado a lado mostrando el progreso de cada jugador. */
.pvp-lanes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.pvp-lane {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 3px solid transparent;
}
.pvp-lane.me { border-color: var(--accent2); }
.pvp-lane-name {
  font-weight: 800;
  color: #4a3d63;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}
.pvp-lane-name img { width: 26px; height: 26px; border-radius: 50%; }
.pvp-lane-word {
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--primary);
  word-break: break-word;
}
.pvp-lane-tr { color: #7a5cff; font-style: italic; font-weight: 700; min-height: 1.2em; }
.pvp-lane-hint { color: #4a3d63; font-weight: 600; margin: 6px 0; }
.pvp-lane-hint b { color: var(--accent2); font-size: 1.15rem; }
.pvp-lane-progress { color: #2ecc71; font-weight: 800; }

.turn-indicator {
  text-align: center;
  color: white;
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.answer-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.answer-row input {
  flex: 1;
  padding: 14px 16px;
  border-radius: 12px;
  border: none;
  font-size: 1.1rem;
}
.answer-row button { min-width: 110px; }

.feedback {
  min-height: 26px;
  text-align: center;
  font-weight: 800;
  margin-bottom: 14px;
  color: white;
}
.feedback.ok { color: #b6ffb0; }
.feedback.err { color: #ffb0b0; }

.scoreboard {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.scoreboard h3 { margin-top: 0; color: var(--primary); }
.scoreboard ul { list-style: none; padding: 0; margin: 0; }

.host-review {
  background: #fff3cd;
  border: 2px solid var(--accent4);
  border-radius: 12px;
  padding: 14px;
  margin-top: 14px;
  text-align: center;
}
.host-review button { margin: 6px; }

#end-results { color: white; }
.end-rank {
  background: var(--card-bg);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-weight: 700;
}
.end-rank .place { font-size: 1.4rem; }

/* Cadena de palabras completa (expandible, va creciendo visualmente) */
.chain-history-box { margin-bottom: 14px; }
.chain-toggle {
  background: rgba(255,255,255,0.15);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 700;
  width: 100%;
  text-align: left;
}
.chain-toggle:hover { background: rgba(255,255,255,0.25); }
.chain-history-list {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  box-shadow: var(--shadow);
}
.chain-history-list .link {
  background: #efe8fb;
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.chain-history-list .link .tr { color: #7a5cff; font-weight: 600; font-size: 0.72rem; font-style: italic; }
.chain-history-list .link .n { color: #9a8db8; font-weight: 600; font-size: 0.72rem; }
.chain-history-list .arrow { color: #b7abd6; align-self: center; }

/* Modo asistido: opciones en vez de escribir */
.assist-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 500px) {
  .assist-options { grid-template-columns: 1fr; }
}
.assist-option-btn {
  background: var(--card-bg);
  border: 3px solid transparent;
  border-radius: 12px;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.assist-option-btn:hover { transform: translateY(-3px); border-color: var(--accent4); }
.assist-option-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Panel de pistas del modo aprendizaje */
.learn-hints {
  background: #eaf7ff;
  border: 2px solid var(--accent3);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.learn-hints h4 { margin: 0 0 8px; color: var(--accent3); }
.verb-hint {
  margin-top: 10px;
  background: white;
  border-radius: 10px;
  padding: 10px;
  font-weight: 700;
  color: var(--primary);
}
.verb-hint .vf { color: var(--accent2); }

/* Visor de diccionario */
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
  background: #f4f0fb;
  border-radius: 12px;
}
.word-grid .word-chip {
  background: white;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  color: var(--primary);
  border: 1px solid #e3dcf0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.word-grid .word-chip .tr {
  color: #7a5cff;
  font-weight: 500;
  font-size: 0.78rem;
  font-style: italic;
}
#dict-filter {
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid #e3dcf0;
  font-size: 1rem;
}
