/* ============================================================
   Bacteri_Escaleras — estilos
   ============================================================ */
:root {
  --bg1: #0b2027;
  --bg2: #16404d;
  --accent: #2ec4b6;
  --accent2: #ffd166;
  --danger: #ff5a5f;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.14);
  --text: #f3f7f7;
  --muted: #a7c0c4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 700px at 80% -10%, #1d5562 0%, transparent 60%),
              radial-gradient(900px 600px at -10% 110%, #1a3f4a 0%, transparent 55%),
              linear-gradient(160deg, var(--bg1), var(--bg2));
  min-height: 100vh;
  padding: 18px;
}

.hidden { display: none !important; }

/* ---------- Encabezado ---------- */
.app-header {
  text-align: center;
  margin-bottom: 18px;
}
.app-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  letter-spacing: 0.5px;
}
.app-header h1 .em { color: var(--accent); }
.app-header p { color: var(--muted); margin-top: 4px; font-size: 0.95rem; }

/* ---------- Pantalla de inicio ---------- */
#setup {
  max-width: 520px;
  margin: 4vh auto;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 28px;
  backdrop-filter: blur(6px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
#setup h2 { font-size: 1.2rem; margin-bottom: 6px; }
.setup-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 18px; }

.count-row { display: flex; gap: 10px; margin: 10px 0 18px; }
.count-btn {
  flex: 1;
  padding: 14px 0;
  font-size: 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: 0.15s;
}
.count-btn:hover { border-color: var(--accent); }
.count-btn.active { background: var(--accent); color: #06231f; font-weight: 700; border-color: var(--accent); }

#names-wrap { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.name-row { display: flex; align-items: center; gap: 10px; }
.color-dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,0.25); }
.name-input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 1rem;
}
.name-input:focus { outline: 2px solid var(--accent); }

.setup-actions { display: flex; gap: 10px; }
.btn-primary {
  flex: 1;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #1f9c90);
  color: #06231f;
  cursor: pointer;
  transition: 0.15s;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost {
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); }

/* ---------- Layout del juego ---------- */
#game { max-width: 1100px; margin: 0 auto; }
.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) {
  .game-grid { grid-template-columns: 1fr; }
}

/* ---------- Tablero ---------- */
.board-wrap { position: relative; }
#board {
  --size: 7;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  gap: 5px;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px;
  border-radius: 16px;
  border: 1px solid var(--card-border);
  aspect-ratio: 1 / 1;
}
.cell {
  position: relative;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 3px;
  font-size: 0.7rem;
  min-height: 0;
  overflow: hidden;
}
.cell-num {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 0.62rem;
  color: var(--muted);
  font-weight: 600;
}
.cell-badge {
  font-size: 0.6rem;
  line-height: 1.1;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  word-break: break-word;
}
.cell.start { background: linear-gradient(135deg, rgba(46,196,182,0.35), rgba(46,196,182,0.1)); border-color: var(--accent); }
.cell.finish { background: linear-gradient(135deg, rgba(255,209,102,0.35), rgba(255,209,102,0.1)); border-color: var(--accent2); }
.cell.ladder-cell { background: rgba(46, 196, 182, 0.12); }
.cell.snake-cell { background: rgba(255, 90, 95, 0.14); }
.cell.q-cell { background: rgba(90, 125, 255, 0.16); }
.cell.q-cell .cell-badge { font-size: 1rem; }

.token-layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
}
.token {
  width: clamp(12px, 2.2vw, 20px);
  height: clamp(12px, 2.2vw, 20px);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  font-size: 0.62rem;
  font-weight: 800;
  color: #06231f;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

/* Overlay SVG escaleras/serpientes */
#overlay {
  position: absolute;
  top: 8px; left: 8px;
  pointer-events: none;
  z-index: 5;
}
.ladder-rail { stroke: #9be7df; stroke-width: 3; stroke-linecap: round; opacity: 0.85; }
.ladder-rung { stroke: #cffaf4; stroke-width: 2; stroke-linecap: round; opacity: 0.7; }
.snake-body { stroke: var(--danger); stroke-width: 6; fill: none; stroke-linecap: round; opacity: 0.8; }
.snake-head { fill: var(--danger); stroke: #fff; stroke-width: 1.5; }

/* ---------- Panel lateral ---------- */
.side-panel { display: flex; flex-direction: column; gap: 16px; }
.panel-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
}
#turn-indicator { font-size: 1.15rem; font-weight: 800; text-align: center; margin-bottom: 12px; }

.dice-row { display: flex; align-items: center; justify-content: center; gap: 16px; }
#dice {
  font-size: 3.4rem;
  line-height: 1;
  width: 70px;
  text-align: center;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}
#dice.rolling { animation: shake 0.3s infinite; }
@keyframes shake {
  0%,100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
#roll-btn {
  padding: 14px 22px;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent2), #f0a93f);
  color: #3a2700;
  cursor: pointer;
  transition: 0.15s;
}
#roll-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
#roll-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#players-panel { display: flex; flex-direction: column; gap: 8px; }
.player-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  font-size: 0.92rem;
  transition: 0.15s;
}
.player-card.active { border-color: var(--accent); background: rgba(46, 196, 182, 0.12); transform: scale(1.02); }
.pc-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.pc-name { font-weight: 700; flex: 1; }
.pc-pos { color: var(--muted); font-size: 0.8rem; }

#log {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}
.log-line {
  padding: 6px 9px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  color: var(--muted);
}
.log-line:first-child { color: var(--text); background: rgba(46, 196, 182, 0.1); }

.panel-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; }
.mini-actions { display: flex; gap: 8px; }
.mini-btn {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}
.mini-btn:hover { border-color: var(--accent); }

/* ---------- Modales ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 14, 17, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 18px;
  backdrop-filter: blur(3px);
}
.modal-box {
  background: linear-gradient(160deg, #103642, #0b2730);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 26px;
  max-width: 540px;
  width: 100%;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box h2 { margin-bottom: 8px; }
#q-player { font-weight: 700; margin-bottom: 6px; }
#q-text { font-size: 1.15rem; font-weight: 700; margin-bottom: 16px; line-height: 1.35; }
#q-options { display: flex; flex-direction: column; gap: 10px; }
.q-option {
  text-align: left;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  transition: 0.12s;
}
.q-option:hover:not(:disabled) { border-color: var(--accent); background: rgba(46,196,182,0.12); }
.q-option:disabled { cursor: default; }
.q-option.correct { background: rgba(46, 196, 182, 0.3); border-color: var(--accent); }
.q-option.wrong { background: rgba(255, 90, 95, 0.3); border-color: var(--danger); }
.q-feedback { margin-top: 14px; padding: 12px; border-radius: 10px; font-size: 0.95rem; line-height: 1.4; }
.q-feedback.good { background: rgba(46, 196, 182, 0.18); }
.q-feedback.bad { background: rgba(255, 90, 95, 0.18); }
.q-continue {
  margin-top: 14px;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #06231f;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.q-continue:hover { filter: brightness(1.08); }

.rules-list { margin: 12px 0 18px 18px; line-height: 1.7; }
.rules-list li { margin-bottom: 4px; }
.legend { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 18px; }
.legend span { display: flex; align-items: center; gap: 8px; }

.win-box { text-align: center; }
.win-box .trophy { font-size: 4rem; }
#win-name { font-size: 1.8rem; font-weight: 900; margin: 8px 0 4px; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

.credits { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 22px; }
.app-footer { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 20px 10px 10px; letter-spacing: 0.3px; }

/* ---------- Modal información ---------- */
.info-player { font-weight: 700; margin-bottom: 8px; }
.info-text { font-size: 1.15rem; line-height: 1.5; margin-bottom: 18px; }
.info-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.info-actions .mini-btn { flex: 1; min-width: 140px; padding: 12px; }
.info-actions .q-continue { flex: 1; min-width: 140px; margin-top: 0; }

/* ---------- QR en el header ---------- */
.app-header { position: relative; }
.header-qr {
  position: absolute;
  top: 0;
  right: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  background: #fff;
  padding: 6px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}
.header-qr:hover { transform: scale(1.05); }
.header-qr img { display: block; width: 76px; height: 76px; }
.header-qr span { font-size: 0.7rem; font-weight: 700; color: #0b2027; }
@media (max-width: 720px) {
  .header-qr { position: static; margin: 0 auto 12px; width: max-content; }
}

/* ---------- Cierre URAT (pantalla de victoria) ---------- */
.urat-cierre {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(46, 196, 182, 0.14);
  border: 1px solid var(--accent);
  text-align: left;
}
.urat-cierre h3 { font-size: 1rem; margin-bottom: 8px; text-align: center; }
.urat-cierre p { font-size: 0.9rem; margin: 4px 0; color: var(--text); }

/* ---------- Modal intro (video) ---------- */
.intro-box { max-width: 760px; }
#intro-video {
  width: 100%;
  max-height: 62vh;
  border-radius: 12px;
  background: #000;
  display: block;
}

/* ---------- Casilla educativa — mensaje clave ---------- */
.info-clave {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(46, 196, 182, 0.2), rgba(46, 196, 182, 0.08));
  border-left: 4px solid var(--accent);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--accent);
}

/* ---------- Victoria V2 — mensaje final ---------- */
.win-checklist {
  list-style: none;
  padding: 0;
  margin: 10px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
.win-checklist li {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  font-size: 0.92rem;
}
.win-highlight {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(255, 90, 95, 0.15);
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--accent2);
}
.win-final {
  margin-top: 10px;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
  line-height: 1.45;
}

/* ---------- Video del mensaje final (pantalla de victoria) ---------- */
.final-video {
  width: 100%;
  max-height: 46vh;
  border-radius: 12px;
  background: #000;
  display: block;
  margin: 14px 0 4px;
}
