/* Zócalo Games — Sopa de Letras */

/* Respaldo: mismo estilo que .puzzle-grid-title de puzzle-grid.css, por si
   esta página tiene el shortcode de sopa de letras sin el de puzzle/crucigrama
   y por lo tanto no carga ese archivo. No pisa nada si sí está cargado —
   son las mismas reglas. */
.puzzle-grid-title {
	text-align: center;
	font-size: 32px;
	font-weight: 700;
	color: #1a1a1a;
	margin-bottom: 40px;
}

.wordsearch-card {
	background: #fff;
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.wordsearch-card:hover {
	transform: translateY(-8px);
	box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.wordsearch-card-extra {
	display: none;
}

.wordsearch-card-image {
	position: relative;
	width: 100%;
	padding-bottom: 75%;
	overflow: hidden;
	/* Degradado de respaldo si todavía no hay imagen OG generada — evita
	   que la tarjeta se vea rota mientras no se ha guardado el post. */
	background: linear-gradient(135deg, #1e3a8a, #2563eb);
}

.wordsearch-card-image img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease-out;
}

.wordsearch-card:hover .wordsearch-card-image img {
	transform: scale(1.05);
}

/* Vista previa de la cuadrícula real como portada de la tarjeta (mismo
   enfoque que la vista previa del crucigrama). */
.wordsearch-preview {
	position: absolute;
	top: 50%;
	left: 50%;
	height: 86%;
	aspect-ratio: 1 / 1;
	transform: translate(-50%, -50%);
	transition: transform 0.4s ease-out;
	container-type: size;
	background: #dde2ee;
	border-radius: 6px;
	overflow: hidden;
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
}

.wordsearch-card:hover .wordsearch-preview {
	transform: translate(-50%, -50%) scale(1.04);
}

.wordsearch-preview-grid {
	display: grid;
	grid-template-columns: repeat(var(--n), 1fr);
	grid-template-rows: repeat(var(--n), 1fr);
	gap: 1px;
	width: 100%;
	height: 100%;
}

.wordsearch-preview-grid b {
	display: flex !important;
	align-items: center;
	justify-content: center;
	margin: 0 !important;
	padding: 0 !important;
	background: #ffffff !important;
	color: #26304a !important;
	font-size: 8px;
	font-weight: 700 !important;
	line-height: 1 !important;
	text-transform: none !important;
}

/* La letra mide ~56% de la altura de su celda (cqh = % de la altura del cuadro). */
@supports (font-size: 1cqh) {
	.wordsearch-preview-grid b {
		font-size: calc(100cqh / var(--n) * 0.56);
	}
}

.wordsearch-preview-grid b.w0 { background: #ffd6d6 !important; }
.wordsearch-preview-grid b.w1 { background: #ffe8b3 !important; }
.wordsearch-preview-grid b.w2 { background: #fff6b3 !important; }
.wordsearch-preview-grid b.w3 { background: #d9f7be !important; }
.wordsearch-preview-grid b.w4 { background: #b3f0e0 !important; }
.wordsearch-preview-grid b.w5 { background: #b3e5ff !important; }

.wordsearch-card-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(200, 16, 46, 0.8);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.3s ease-out;
	z-index: 10;
}

.wordsearch-card:hover .wordsearch-card-overlay {
	opacity: 1;
}

.wordsearch-card-play {
	background: #fff;
	color: #c8102e;
	border: none;
	padding: 12px 32px;
	border-radius: 6px;
	font-weight: 700;
	font-size: 16px;
	cursor: pointer;
	transition: all 0.3s ease;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
	transform: scale(0.9);
}

.wordsearch-card:hover .wordsearch-card-play {
	transform: scale(1);
}

.wordsearch-card-info {
	padding: 20px;
	text-align: center;
}

.wordsearch-card-info h3 {
	font-size: 18px;
	font-weight: 700;
	color: #1a1a1a;
	margin: 0 0 8px;
}

.wordsearch-card-difficulty {
	color: #c8102e;
	font-weight: 600;
	font-size: 13px;
	margin: 4px 0;
}

.wordsearch-card-words {
	color: #999;
	font-size: 12px;
	margin: 4px 0 12px;
}

.wordsearch-ranking-toggle {
	display: block;
	width: 100%;
	padding: 8px 0;
	background: transparent;
	border: 1.5px solid #c8102e;
	border-radius: 8px;
	color: #c8102e;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	text-align: center;
}

.wordsearch-ranking-toggle:hover,
.wordsearch-ranking-toggle[aria-expanded="true"] {
	background: #c8102e;
	color: #fff;
}

.wordsearch-ranking-panel {
	margin-top: 12px;
	padding: 12px;
	background: #fafafa;
	border: 1px solid #e8e8e8;
	border-radius: 8px;
	text-align: left;
}

.wordsearch-ranking-loading,
.wordsearch-ranking-empty {
	text-align: center;
	color: #999;
	font-size: 13px;
	padding: 8px 0;
	margin: 0;
}

.wordsearch-ranking-list {
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: 13px;
}

.wordsearch-ranking-list li {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 0;
	border-bottom: 1px solid #f0f0f0;
}

.wordsearch-ranking-list li:last-child {
	border-bottom: none;
}

.wordsearch-ranking-medal {
	font-size: 15px;
	min-width: 22px;
}

.wordsearch-ranking-name {
	flex: 1 1 auto;
	min-width: 50px;
	color: #333;
	font-weight: 500;
	white-space: normal;
	overflow-wrap: break-word;
	word-break: break-word;
}

.wordsearch-ranking-time {
	color: #c8102e;
	font-weight: 700;
	font-size: 12px;
	white-space: nowrap;
}

.wordsearch-ranking-diff {
	font-size: 11px;
	color: #999;
	white-space: nowrap;
}

.wordsearch-difficulty-badge {
	display: inline-block;
	font-size: 12px;
	font-weight: 700;
	padding: 4px 10px;
	border-radius: 12px;
	margin: 6px 0;
	text-transform: uppercase;
}

.wordsearch-difficulty-facil {
	background: #d4f4dd;
	color: #1a7431;
}

.wordsearch-difficulty-media {
	background: #fff3cd;
	color: #8a6100;
}

.wordsearch-difficulty-dificil {
	background: #fde0e0;
	color: #a11c1c;
}

.wordsearch-play-btn {
	margin-top: 10px;
	padding: 8px 20px;
	border: none;
	border-radius: 6px;
	background: #c8102e;
	color: #fff;
	cursor: pointer;
	font-weight: 600;
}

.wordsearch-ver-mas {
	display: block;
	margin: 20px auto 0;
	padding: 10px 24px;
	border: 1px solid #c8102e;
	background: transparent;
	color: #c8102e;
	border-radius: 6px;
	cursor: pointer;
}

/* Modal */
.wordsearch-modal-backdrop {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: #ffffff !important;
	z-index: 99999;
	overflow-y: auto;
	box-sizing: border-box;
	padding: 40px 20px;
}

.wordsearch-modal-box {
	background: #ffffff !important;
	max-width: 900px;
	width: 100%;
	margin: 0 auto;
	position: relative;
	box-sizing: border-box;
	text-align: center;
}

.wordsearch-modal-close-btn {
	position: fixed;
	top: 16px;
	right: 20px;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	color: #333;
	z-index: 100000;
	background: #fff;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.wordsearch-modal-title {
	margin: 0 0 4px;
}

/* Tablero */
.wordsearch-timer {
	font-family: monospace;
	font-size: 18px;
	font-weight: 700;
	text-align: center;
	margin-bottom: 20px;
}

.wordsearch-board {
	display: grid;
	gap: 2px;
	background: #dddddd !important;
	border: 2px solid #333;
	user-select: none;
	touch-action: none; /* evita scroll del navegador al arrastrar dentro del tablero */
	margin: 0 auto 16px;
	max-width: 600px;
}

.wordsearch-cell {
	aspect-ratio: 1 / 1;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #ffffff !important;
	font-weight: 700;
	font-family: monospace;
	cursor: pointer;
	box-sizing: border-box; /* defensivo contra el tema temalimpio */
	margin: 0;
	padding: 0;
}

.wordsearch-cell.wordsearch-selecting {
	background: #ffe08a !important;
}

.wordsearch-cell.wordsearch-found {
	color: #1a1a1a;
	font-weight: 700;
}

.wordsearch-word-list {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-bottom: 16px;
}

.wordsearch-word-chip {
	padding: 4px 10px;
	background: #f0f0f0;
	border-radius: 4px;
	font-size: 13px;
	font-weight: 600;
}

.wordsearch-word-chip.wordsearch-word-found {
	background: #a8e6a1;
	color: #1a7431;
	text-decoration: line-through;
}

.wordsearch-complete-panel {
	text-align: center;
	padding: 16px;
	background: #f0fff4;
	border-radius: 8px;
}

.wordsearch-name-form {
	display: flex;
	gap: 8px;
	justify-content: center;
	align-items: stretch;
	flex-wrap: wrap;
	margin-top: 10px;
	max-width: 420px;
	margin-left: auto;
	margin-right: auto;
}

.wordsearch-name-form input {
	box-sizing: border-box !important;
	height: 44px !important;
	padding: 0 14px !important;
	border: 2px solid #c8102e !important;
	border-radius: 8px !important;
	background: #fff !important;
	width: 180px !important;
	max-width: 100%;
	font-size: 14px !important;
	color: #1a1a1a !important;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wordsearch-name-form input:focus {
	outline: none !important;
	border-color: #a10d24 !important;
	box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15) !important;
}

.wordsearch-name-form .wordsearch-action-btn {
	height: 44px;
	margin: 0;
	box-sizing: border-box;
}

.wordsearch-save-msg {
	font-size: 12px;
	color: #888;
	margin-top: 8px;
}

.wordsearch-complete-actions {
	display: flex;
	gap: 10px;
	justify-content: center;
	flex-wrap: wrap;
	margin-top: 10px;
}

.wordsearch-action-btn {
	padding: 8px 20px;
	border: 1px solid #c8102e;
	border-radius: 6px;
	background: #fff;
	color: #c8102e;
	cursor: pointer;
	font-weight: 600;
}

.wordsearch-share-btn {
	padding: 8px 20px;
	border: none;
	border-radius: 6px;
	background: #1877f2;
	color: #fff;
	cursor: pointer;
	font-weight: 600;
}
