:root {
  --verde-pano: #1e4638;
  --verde-pano-2: #123028;
  --madera: #3a2317;
  --dorado: #c9a227;
  --dorado-claro: #e8cf7a;
  --crema: #fbf6ea;
  --tinta: #211a12;
  --rojo: #a12f2f;
  --gris: #55605c;
  --exito: #3f8f5f;
  --sombra: rgba(0,0,0,0.35);

  --c-espada: #2b3a4a;
  --c-basto: #4b6b2f;
  --c-copa: #a12f2f;
  --c-oro: #b8860b;

  --fuente-display: 'Fraunces', serif;
  --fuente-cuerpo: 'Manrope', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--fuente-cuerpo);
  color: var(--crema);
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255,255,255,0.06), transparent 55%),
    var(--verde-pano);
}

#app { min-height: 100vh; }

.pantalla { display: none; min-height: 100vh; }
.pantalla.activa { display: block; }

button { font-family: var(--fuente-cuerpo); cursor: pointer; }
input { font-family: var(--fuente-cuerpo); }

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primario { background: linear-gradient(180deg, var(--dorado-claro), var(--dorado)); color: var(--tinta); box-shadow: 0 4px 0 #8a6c14, 0 8px 14px var(--sombra); }
.btn-primario:not(:disabled):hover { box-shadow: 0 5px 0 #8a6c14, 0 10px 18px var(--sombra); }

.btn-secundario { background: transparent; color: var(--crema); border: 1.5px solid rgba(251,246,234,0.5); }
.btn-secundario:hover { border-color: var(--crema); }

.btn-toggle { background: rgba(251,246,234,0.12); color: var(--crema); border: 1.5px solid transparent; }
.btn-toggle.activo { background: var(--exito); }

.btn-mini { background: rgba(0,0,0,0.25); color: var(--crema); border: 1px solid rgba(255,255,255,0.2); padding: 0.5rem 0.9rem; font-size: 0.85rem; border-radius: 8px; }

/* ===== PANTALLA INICIO ===== */
.marco-inicio {
  max-width: 900px;
  margin: 0 auto;
  padding: 5vh 1.5rem 3rem;
}
.marca { text-align: center; margin-bottom: 2.5rem; }
.marca-icono { font-size: 2.5rem; display: block; margin-bottom: 0.25rem; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)); }
.marca h1 {
  font-family: var(--fuente-display);
  font-size: 4rem;
  margin: 0;
  color: var(--dorado-claro);
  letter-spacing: 0.02em;
  text-shadow: 0 3px 0 rgba(0,0,0,0.3);
}
.subtitulo { color: rgba(251,246,234,0.75); max-width: 480px; margin: 0.5rem auto 0; font-size: 0.95rem; }

.tarjetas-opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 680px) { .tarjetas-opciones { grid-template-columns: 1fr; } }

.opcion-card {
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(201,162,39,0.35);
  border-radius: 16px;
  padding: 1.75rem;
}
.opcion-card h2 { font-family: var(--fuente-display); margin-top: 0; color: var(--dorado-claro); font-size: 1.4rem; }
.opcion-card label { display: block; font-size: 0.82rem; color: rgba(251,246,234,0.7); margin-bottom: 1rem; }
.opcion-card input {
  display: block; width: 100%; margin-top: 0.35rem;
  padding: 0.6rem 0.75rem; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06); color: var(--crema); font-size: 0.95rem;
}
.opcion-card .btn { width: 100%; margin-top: 0.25rem; }

.error-mensaje { color: #ffb4b4; text-align: center; min-height: 1.2em; margin-top: 1rem; font-size: 0.9rem; }

/* ===== LOBBY ===== */
.marco-lobby { max-width: 620px; margin: 0 auto; padding: 6vh 1.5rem; }
.lobby-header h2 { font-family: var(--fuente-display); color: var(--dorado-claro); margin-bottom: 0.25rem; }
.codigo-chip { background: var(--dorado); color: var(--tinta); padding: 0.15rem 0.6rem; border-radius: 8px; font-family: monospace; letter-spacing: 0.1em; }
.lobby-ayuda { color: rgba(251,246,234,0.65); font-size: 0.88rem; }

.lista-jugadores { list-style: none; padding: 0; margin: 1.5rem 0; display: flex; flex-direction: column; gap: 0.6rem; }
.lista-jugadores li {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(0,0,0,0.22); border-radius: 10px; padding: 0.7rem 1rem;
  border-left: 4px solid rgba(201,162,39,0.5);
}
.lista-jugadores li.este-soy-yo { border-left-color: var(--dorado); }
.jugador-nombre { font-weight: 600; }
.jugador-tag { font-size: 0.72rem; opacity: 0.7; margin-left: 0.4rem; }
.estado-listo { font-size: 0.8rem; padding: 0.25rem 0.6rem; border-radius: 20px; background: rgba(255,255,255,0.1); }
.estado-listo.si { background: var(--exito); }

.lobby-acciones { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.lobby-acciones .btn { flex: 1 1 auto; }

/* ===== MESA DE JUEGO ===== */
#pantalla-juego { display: none; }
#pantalla-juego.activa { display: grid; grid-template-columns: 1fr 280px; gap: 0; min-height: 100vh; }
@media (max-width: 900px) { #pantalla-juego.activa { grid-template-columns: 1fr; } .panel-log { display: none; } }

.mesa {
  padding: 1rem 1rem 1.25rem;
  display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 50% 40%, var(--verde-pano) 0%, var(--verde-pano-2) 100%);
  min-height: 100vh;
}

.mesa-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.info-ronda { font-family: var(--fuente-display); font-size: 1.1rem; color: var(--dorado-claro); display: flex; gap: 0.6rem; align-items: center; }
.chip-direccion { font-size: 0.72rem; background: rgba(0,0,0,0.3); padding: 0.2rem 0.55rem; border-radius: 20px; font-family: var(--fuente-cuerpo); }

.oponentes { display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; padding: 0.5rem 0 1rem; }
.oponente {
  background: rgba(0,0,0,0.2); border-radius: 12px; padding: 0.6rem 0.9rem; text-align: center;
  min-width: 92px; border: 2px solid transparent;
}
.oponente.turno-activo { border-color: var(--dorado); box-shadow: 0 0 14px rgba(201,162,39,0.5); }
.oponente.desconectado { opacity: 0.5; }
.oponente-nombre { font-size: 0.85rem; font-weight: 700; display: block; }
.oponente-cartas { font-size: 0.75rem; color: rgba(251,246,234,0.75); }
.mini-stack { position: relative; height: 36px; margin: 0.4rem auto 0.3rem; }
.mini-dorso {
  position: absolute; top: 0; width: 24px; height: 34px; border-radius: 4px;
  background: repeating-linear-gradient(45deg, #7a1f1f, #7a1f1f 4px, #611818 4px, #611818 8px);
  border: 2px solid var(--dorado);
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
  transition: left .2s ease;
}

.centro-mesa { display: flex; align-items: center; justify-content: center; gap: 2.5rem; padding: 1rem 0; position: relative; }
.mazo-pila { position: relative; cursor: pointer; text-align: center; }
.carta-dorso { background: repeating-linear-gradient(45deg, #7a1f1f, #7a1f1f 5px, #611818 5px, #611818 10px); border: 2px solid var(--dorado); }
.conteo-mazo { display: block; margin-top: 0.4rem; font-size: 0.78rem; color: rgba(251,246,234,0.7); }

.descarte-pila { text-align: center; }
.palo-efectivo { margin-top: 0.4rem; font-size: 0.78rem; color: var(--dorado-claro); min-height: 1.1em; }

.pendientes { position: absolute; right: -0.5rem; top: -1.2rem; }
.chip-pendiente { background: var(--rojo); color: white; padding: 0.3rem 0.7rem; border-radius: 20px; font-size: 0.78rem; font-weight: 700; box-shadow: 0 3px 8px var(--sombra); }

.turno-banner {
  text-align: center; font-family: var(--fuente-display); font-size: 1.1rem;
  color: var(--dorado-claro); min-height: 1.6em; margin-bottom: 0.4rem;
}

.mano-jugador-zona { margin-top: auto; }
.mano-controles { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; flex-wrap: wrap; gap: 0.5rem; }
.switch-una { font-size: 0.8rem; color: rgba(251,246,234,0.8); display: flex; align-items: center; gap: 0.4rem; }

.mano-jugador {
  display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.5rem 0.25rem 0.75rem;
  justify-content: center; flex-wrap: wrap;
}

.carta {
  width: 64px; height: 92px; border-radius: 8px; background: var(--crema);
  box-shadow: 0 3px 8px var(--sombra);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--tinta); font-weight: 800; position: relative; flex-shrink: 0;
  border: 2px solid rgba(0,0,0,0.08);
}
.carta .valor { font-size: 1.3rem; line-height: 1; }
.carta .simbolo { font-size: 1.5rem; line-height: 1; margin-top: 0.15rem; }
.carta.comodin { background: linear-gradient(160deg, #2b2b2b, #4a4a4a); color: var(--dorado-claro); }
.carta.comodin .valor { font-size: 0.85rem; letter-spacing: 0.05em; }

.carta.jugable { cursor: pointer; transform: translateY(0); border-color: var(--dorado); box-shadow: 0 3px 8px var(--sombra), 0 0 0 2px rgba(201,162,39,0.4); }
.carta.jugable:hover { transform: translateY(-8px); }
.carta.no-jugable { opacity: 0.55; cursor: not-allowed; }

.color-espada, .color-basto { color: var(--c-espada); }
.color-basto { color: var(--c-basto); }
.color-copa { color: var(--c-copa); }
.color-oro { color: var(--c-oro); }

/* ===== PANEL LOG ===== */
.panel-log { background: rgba(0,0,0,0.28); padding: 1.25rem; border-left: 1px solid rgba(201,162,39,0.3); overflow-y: auto; }
.panel-log h3 { font-family: var(--fuente-display); color: var(--dorado-claro); margin-top: 0; font-size: 1.05rem; }
.panel-log ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.panel-log li { font-size: 0.82rem; color: rgba(251,246,234,0.85); border-bottom: 1px dashed rgba(255,255,255,0.08); padding-bottom: 0.5rem; }

/* ===== MODALES ===== */
.modal-fondo {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal-fondo.activo { display: flex; }
.modal-caja {
  background: var(--crema); color: var(--tinta); border-radius: 14px; padding: 1.75rem;
  max-width: 420px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.modal-caja h3 { font-family: var(--fuente-display); margin-top: 0; }
.opciones-palo { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 1rem; }
.opcion-palo { padding: 0.9rem; border-radius: 10px; border: 2px solid rgba(0,0,0,0.1); background: white; font-weight: 700; font-size: 1rem; }
.opcion-palo:hover { border-color: var(--dorado); }

.opciones-objetivo { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }
.opciones-objetivo button { padding: 0.75rem; border-radius: 10px; border: 2px solid rgba(0,0,0,0.1); background: white; font-weight: 700; text-align: left; }
.opciones-objetivo button:hover { border-color: var(--dorado); }

.lista-puntajes { list-style: none; padding: 0; margin: 1rem 0; }
.lista-puntajes li { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid rgba(0,0,0,0.08); font-weight: 600; }
.lista-puntajes li.ganador { color: var(--exito); }

#btn-cerrar-puntajes, #btn-volver-inicio { width: 100%; margin-top: 0.5rem; }
