/* Entre Mares - estilos de los juegos de Gotalina */
.emg-root { scroll-margin-top: 130px; color: #0a3b7a; }
.emg-view[hidden] { display: none; }
.emg-root img { max-width: 100%; }

/* ---------- Botones ---------- */
.emg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 20px;
	border-radius: 14px;
	border: 2px solid transparent;
	font: 800 0.95rem 'Nunito', sans-serif;
	cursor: pointer;
	text-decoration: none;
	transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.emg-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.emg-btn--primary {
	background: linear-gradient(135deg, #ffd547, #ffb830);
	color: #0a3b7a;
	box-shadow: 0 8px 20px rgba(255, 184, 48, 0.4);
}
.emg-btn--primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(255, 184, 48, 0.5); }
.emg-btn--ghost {
	background: #ffffff;
	color: #0a3b7a;
	border-color: rgba(10, 59, 122, 0.2);
}
.emg-btn--ghost:hover:not(:disabled) { background: #eaf4ff; border-color: #0e5fa6; }
.emg-btn:focus-visible, .emg-card:focus-visible { outline: 3px solid #0e5fa6; outline-offset: 2px; }

/* ---------- Menú ---------- */
.emg-progress {
	display: flex;
	align-items: center;
	gap: 18px;
	max-width: 760px;
	margin: 0 auto 26px;
	padding: 14px 22px;
	background: #ffffff;
	border-radius: 20px;
	border: 2px solid rgba(10, 59, 122, 0.08);
	box-shadow: 0 12px 28px rgba(10, 59, 122, 0.08);
}
.emg-progress img { width: 64px; height: 64px; object-fit: contain; flex: 0 0 auto; animation: emg-bob 2.6s ease-in-out infinite; }
.emg-progress-body { flex: 1; min-width: 0; }
.emg-progress-body strong { display: block; font-family: 'Fredoka', sans-serif; font-size: 1.15rem; font-weight: 600; }
.emg-progress-body small { color: #5f779e; font-weight: 600; }
.emg-bar { height: 12px; border-radius: 999px; background: #e3effb; margin: 8px 0 6px; overflow: hidden; }
.emg-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #1db876, #ffd547); transition: width 0.5s ease; }
.emg-progress.is-all { border-color: #ffd547; background: #fffbea; }

.emg-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	gap: 20px;
}
.emg-card {
	display: flex;
	flex-direction: column;
	text-align: left;
	padding: 0;
	background: #ffffff;
	border: 2px solid rgba(10, 59, 122, 0.08);
	border-radius: 20px;
	overflow: hidden;
	cursor: pointer;
	font-family: inherit;
	color: inherit;
	box-shadow: 0 12px 28px rgba(10, 59, 122, 0.08);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.emg-card:hover { transform: translateY(-4px); box-shadow: 0 18px 36px rgba(10, 59, 122, 0.16); }
.emg-card-thumb { position: relative; display: block; aspect-ratio: 16 / 10; background: #cbe9ff; overflow: hidden; }
.emg-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.emg-card-emoji { width: 100%; height: 100%; display: grid; place-items: center; }
.emg-card-emoji span { font-size: 4rem; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25)); }
.emg-card-ok {
	position: absolute; top: 10px; right: 10px;
	width: 34px; height: 34px; border-radius: 50%;
	background: #1db876; color: #fff; display: grid; place-items: center;
	font-weight: 900; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); border: 2px solid #fff;
}
.emg-card-body { display: block; padding: 14px 16px 6px; flex: 1; }
.emg-card-body b { display: block; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 1.05rem; line-height: 1.25; margin-bottom: 4px; }
.emg-card-body span { display: block; color: #5f779e; font-size: 0.86rem; line-height: 1.4; }
.emg-card-cta { display: block; padding: 6px 16px 14px; font-weight: 800; color: #0e5fa6; font-size: 0.9rem; }
.emg-card.is-done { border-color: #1db876; }
.emg-card.is-bonus { border-color: #ffd547; }

/* ---------- Pantalla de juego ---------- */
.emg-stage-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.emg-stage-top h3 { margin: 0; font-family: 'Fredoka', sans-serif; font-size: clamp(1.1rem, 3vw, 1.5rem); font-weight: 600; }
.emg-howto {
	display: flex; align-items: center; gap: 12px;
	max-width: 900px; margin: 0 auto 18px;
	padding: 10px 18px 10px 12px;
	background: #fffbea; border: 2px solid #ffd547; border-radius: 18px;
}
.emg-howto img { width: 54px; height: 54px; object-fit: contain; flex: 0 0 auto; }
.emg-howto p { margin: 0; font-weight: 700; color: #6b5200; }
.emg-stage-area { max-width: 1000px; margin: 0 auto; }
.emg-play { width: 100%; }
.emg-hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; max-width: 980px; margin: 0 auto 12px; }
.emg-hud--center { justify-content: center; margin-top: 16px; }
.emg-count { font: 700 1.3rem 'Fredoka', sans-serif; }
.emg-msg { margin: 8px auto; max-width: 980px; font-weight: 700; color: #0e5fa6; text-align: center; min-height: 1.4em; }
.emg-hud .emg-msg { margin: 0; text-align: left; flex: 1 1 260px; }

/* ---------- Gotitas / escena ---------- */
.emg-cover, .emg-scene, .emg-maze { position: relative; overflow: hidden; border-radius: 18px; box-shadow: 0 16px 36px rgba(10, 59, 122, 0.22); background: #cbe9ff; }
.emg-cover { max-width: 520px; margin: 0 auto; cursor: pointer; touch-action: manipulation; }
.emg-cover > img, .emg-scene > img, .emg-maze > img:first-child { display: block; width: 100%; height: auto; -webkit-user-select: none; user-select: none; }
.emg-cover [data-marks], .emg-scene [data-marks] { position: absolute; inset: 0; pointer-events: none; }
.emg-found, .emg-hintring {
	position: absolute; aspect-ratio: 1 / 1; transform: translate(-50%, -50%);
	border-radius: 50%; pointer-events: none;
}
.emg-found { border: 4px solid #ffd547; background: rgba(255, 213, 79, 0.25); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 18px rgba(255, 213, 79, 0.9); animation: emg-pop 0.4s ease; }
.emg-hintring { border: 4px dashed #ffffff; box-shadow: 0 0 22px rgba(255, 255, 255, 0.95); animation: emg-pulse 0.8s ease-in-out infinite; }
.emg-ripple {
	position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px;
	border: 3px solid rgba(255, 255, 255, 0.95); border-radius: 50%; pointer-events: none;
	animation: emg-ripple 0.7s ease-out forwards;
}
.emg-play--scene { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 20px; align-items: start; }
.emg-scene { cursor: crosshair; touch-action: manipulation; }
.emg-oval {
	position: absolute; border: 4px solid #1db876; border-radius: 50%;
	background: rgba(29, 184, 118, 0.14); display: flex; align-items: center; justify-content: center;
	box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85); animation: emg-pop 0.4s ease;
}
.emg-oval i {
	font-style: normal; width: 34px; height: 34px; border-radius: 50%;
	background: #1db876; color: #fff; display: grid; place-items: center; font-weight: 900;
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}
.emg-checklist { background: #fff8e1; border: 3px solid #ffd547; border-radius: 18px; padding: 14px 16px; }
.emg-checklist h4 { margin: 0 0 6px; font: 600 1.15rem 'Fredoka', sans-serif; color: #0e5fa6; }
.emg-checklist ul { list-style: none; margin: 0 0 10px; padding: 0; }
.emg-checklist li { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-weight: 800; color: #0a3b7a; font-size: 0.95rem; }
.emg-check { position: relative; width: 20px; height: 20px; flex: 0 0 auto; border: 2px solid #0e5fa6; border-radius: 6px; background: #fff; }
.emg-checklist li.is-done { color: #128a58; }
.emg-checklist li.is-done .emg-check { background: #1db876; border-color: #1db876; }
.emg-checklist li.is-done .emg-check::after { content: '✔'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 13px; }
.emg-checklist .emg-msg { text-align: left; font-size: 0.88rem; margin: 10px 0 0; }
.emg-checklist .emg-btn { width: 100%; margin-top: 4px; }

/* ---------- Laberinto ---------- */
.emg-maze { max-width: 980px; margin: 0 auto; touch-action: none; cursor: grab; outline: none; -webkit-user-select: none; user-select: none; }
.emg-maze:active { cursor: grabbing; }
.emg-maze:focus-visible { box-shadow: 0 0 0 4px #0e5fa6, 0 16px 36px rgba(10, 59, 122, 0.22); }
.emg-token {
	position: absolute; width: 4.2%; height: auto; transform: translate(-50%, -62%);
	pointer-events: none; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.4));
}
.emg-goal {
	position: absolute; aspect-ratio: 1 / 1; transform: translate(-50%, -50%);
	border: 3px dashed rgba(255, 255, 255, 0.95); border-radius: 50%;
	background: rgba(255, 213, 79, 0.28); pointer-events: none; animation: emg-pulse 1.4s ease-in-out infinite;
}
.emg-maze.is-oops { animation: emg-shake 0.4s; box-shadow: 0 0 0 5px #f53346, 0 16px 36px rgba(245, 51, 70, 0.4); }

/* ---------- Ciclo del agua ---------- */
.emg-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; max-width: 920px; margin: 14px auto 0; }
.emg-cyc {
	position: relative; padding: 0; border: 4px solid transparent; border-radius: 18px;
	background: #fff; overflow: hidden; cursor: pointer;
	box-shadow: 0 10px 24px rgba(10, 59, 122, 0.14); transition: transform 0.2s ease, border-color 0.2s ease;
}
.emg-cyc:hover { transform: translateY(-3px); }
.emg-cyc img { display: block; width: 100%; height: auto; pointer-events: none; }
.emg-num {
	position: absolute; top: 5%; right: 5%; width: 31%; aspect-ratio: 1 / 1; border-radius: 50%;
	background: #fff; border: 3px dashed #e6c34a; display: grid; place-items: center;
	font: 700 clamp(1.1rem, 3vw, 1.9rem) 'Fredoka', sans-serif; color: #fff;
}
.emg-cyc.is-chosen { border-color: #1db876; }
.emg-cyc.is-chosen .emg-num { background: #0e5fa6; border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); }
.emg-cyc.is-wrong { border-color: #f53346; animation: emg-shake 0.4s; }
.emg-cyc.is-wrong .emg-num { background: #f53346; }

/* ---------- ¿Qué pertenece al río? ---------- */
.emg-tray {
	display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
	max-width: 980px; margin: 12px auto 18px; padding: 12px;
	background: #fff8e1; border: 3px dashed #e6c34a; border-radius: 18px;
}
.emg-item {
	width: 84px; height: 102px; padding: 4px; background: #fdf3dc;
	border: 3px solid transparent; border-radius: 14px; cursor: grab; touch-action: none;
	transition: transform 0.18s ease, border-color 0.18s ease, opacity 0.2s ease;
}
.emg-item:hover:not(:disabled) { transform: translateY(-3px); }
.emg-item img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block; }
.emg-item.is-selected { border-color: #0e5fa6; box-shadow: 0 0 0 3px rgba(14, 95, 166, 0.25); transform: translateY(-4px); }
.emg-item.is-placed { opacity: 0.22; filter: grayscale(1); cursor: default; }
.emg-item.is-dragging { opacity: 0.35; }
.emg-item.is-shake { animation: emg-shake 0.4s; border-color: #f53346; }
.emg-ghost {
	position: fixed; width: 78px; height: 96px; padding: 4px; transform: translate(-50%, -60%);
	background: #fdf3dc; border-radius: 12px; box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
	pointer-events: none; z-index: 10001;
}
.emg-ghost img { width: 100%; height: 100%; object-fit: contain; display: block; }
.emg-zones { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 980px; margin: 0 auto; }
.emg-zone { position: relative; border: 4px solid transparent; border-radius: 22px; overflow: hidden; cursor: pointer; outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.emg-zone > img { display: block; width: 100%; height: auto; }
.emg-zone.is-over, .emg-zone:focus-visible { border-color: #ffd547; box-shadow: 0 0 0 4px rgba(255, 213, 79, 0.45), 0 12px 28px rgba(10, 59, 122, 0.25); }
.emg-zone-chips { position: absolute; left: 0; right: 0; bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; padding: 0 6px; pointer-events: none; }
.emg-chip { width: 50px; height: 50px; padding: 3px; background: rgba(255, 248, 225, 0.95); border-radius: 10px; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); animation: emg-pop 0.35s ease; }
.emg-chip img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---------- Sopa de letras ---------- */
.emg-play--words { display: grid; grid-template-columns: minmax(0, 580px) 230px; gap: 22px; justify-content: center; align-items: start; }
.emg-wsgrid {
	display: grid; grid-template-columns: repeat(var(--cols), 1fr);
	background: #ffffff; border: 4px solid #0e5fa6; border-radius: 16px; overflow: hidden;
	touch-action: none; -webkit-user-select: none; user-select: none; box-shadow: 0 14px 30px rgba(10, 59, 122, 0.18);
}
.emg-cell {
	aspect-ratio: 1 / 1; display: grid; place-items: center;
	font: 700 clamp(0.8rem, 3.2vw, 1.35rem) 'Fredoka', sans-serif; color: #0a3b7a;
	border: 1px solid rgba(14, 95, 166, 0.22); background: #f4fbff; cursor: pointer;
}
.emg-cell.is-sel { background: #ffd547; }
.emg-cell.is-found { color: #0a3b7a; }
.emg-cell.c0 { background: #ffb4bd; } .emg-cell.c1 { background: #b8e6ff; } .emg-cell.c2 { background: #c9f0cf; }
.emg-cell.c3 { background: #ffe29a; } .emg-cell.c4 { background: #e0c8ff; } .emg-cell.c5 { background: #ffd0a8; }
.emg-cell.is-hint { animation: emg-pulse-bg 0.7s ease-in-out infinite; }
.emg-play--words .emg-checklist li.is-done { text-decoration: line-through; }

/* ---------- Crucigrama ---------- */
.emg-play--cross { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.emg-xwrap { min-width: 0; }
.emg-xactive { margin: 0 auto 12px; padding: 10px 14px; max-width: 560px; text-align: center; background: #e8f3ff; border-radius: 12px; font-weight: 800; color: #0a3b7a; min-height: 2.6em; }
.emg-xgrid { --cell: min(42px, max(22px, calc((100vw - 52px) / 12))); display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); gap: 2px; justify-content: center; }
.emg-xe { width: var(--cell); height: var(--cell); }
.emg-xc { position: relative; display: block; width: var(--cell); height: var(--cell); background: #fff; border: 2px solid #0e5fa6; border-radius: 6px; cursor: text; }
.emg-xc small { position: absolute; top: 1px; left: 3px; font-size: 0.58rem; font-weight: 900; color: #f53346; line-height: 1; z-index: 1; pointer-events: none; }
.emg-root .emg-xc input, .emg-root .emg-xc input:focus {
	display: block; width: 100%; max-width: none; height: 100%; min-height: 0; margin: 0; padding: 0;
	border: 0; border-radius: 0; box-shadow: none; background: transparent; outline: none; opacity: 1;
	text-align: center; text-transform: uppercase; caret-color: transparent;
	font: 700 clamp(0.95rem, 3vw, 1.4rem) 'Fredoka', sans-serif; color: #0a3b7a;
}
.emg-xc.is-active { background: #fff3c4; }
.emg-xc:focus-within { background: #ffd547; }
.emg-xc.is-wrong { background: #ffd3d8; border-color: #f53346; }
.emg-xc.is-hint { background: #d4f5e6; border-color: #1db876; }
.emg-clues { background: #fff8e1; border: 3px solid #ffd547; border-radius: 18px; padding: 14px 16px; }
.emg-clues h4 { margin: 0 0 6px; font: 600 1.1rem 'Fredoka', sans-serif; color: #0e5fa6; }
.emg-clues h4:not(:first-child) { margin-top: 14px; }
.emg-clues ul { list-style: none; margin: 0; padding: 0; }
.emg-clues li { padding: 5px 8px; border-radius: 8px; font-size: 0.88rem; font-weight: 700; line-height: 1.35; }
.emg-clues li b { color: #f53346; }
.emg-clues li.is-active { background: #ffe9a3; }

/* ---------- Credencial ---------- */
.emg-cred-form { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 0 auto 18px; max-width: 900px; }
.emg-root input.emg-input {
	flex: 1 1 260px; width: auto; max-width: 420px; height: auto; min-height: 0; margin: 0; padding: 13px 18px;
	border: 3px solid #0e5fa6; border-radius: 14px; box-shadow: none;
	font: 700 1.05rem 'Nunito', sans-serif; color: #0a3b7a; background: #fff;
}
.emg-root input.emg-input:focus { outline: 3px solid #ffd547; outline-offset: 2px; box-shadow: none; color: #0a3b7a; background: #fff; }
.emg-cred-canvas { display: block; width: 100%; max-width: 900px; margin: 0 auto; border-radius: 18px; box-shadow: 0 16px 36px rgba(10, 59, 122, 0.22); background: #fff8e1; }

/* ---------- Ventana de logro ---------- */
.emg-modal {
	position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 18px;
	background: rgba(10, 59, 122, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); overflow: hidden;
	animation: em-fade-in 0.3s ease;
}
.emg-modal-card {
	position: relative; z-index: 2; width: min(100%, 440px); padding: 26px 24px 22px; text-align: center;
	background: #ffffff; border-radius: 26px; border: 4px solid #ffd547; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
	animation: emg-pop 0.45s ease;
}
.emg-modal-gota { width: 110px; height: 110px; object-fit: contain; margin: -62px auto 4px; display: block; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.3)); animation: emg-bob 2s ease-in-out infinite; }
.emg-modal-card h3 { margin: 0 0 8px; font: 600 1.55rem 'Fredoka', sans-serif; color: #0a3b7a; }
.emg-modal-card p { margin: 0 0 18px; color: #4a6486; font-weight: 600; line-height: 1.5; }
.emg-modal-actions { display: flex; flex-direction: column; gap: 10px; }
.emg-confetti { position: absolute; top: -40px; z-index: 1; pointer-events: none; animation: emg-fall linear forwards; }

/* ---------- Animaciones ---------- */
@keyframes emg-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes emg-pop { 0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; } 70% { transform: translate(-50%, -50%) scale(1.12); } 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes emg-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes emg-pulse-bg { 0%, 100% { background: #f4fbff; } 50% { background: #ffd547; } }
@keyframes emg-ripple { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }
@keyframes emg-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes emg-fall { to { transform: translateY(115vh) rotate(300deg); } }

/* Los elementos con "translate(-50%,-50%)" necesitan su propia versión de pop */
.emg-oval, .emg-chip, .emg-modal-card { animation-name: emg-pop-plain; }
@keyframes emg-pop-plain { 0% { transform: scale(0.3); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }

/* ---------- Pantallas pequeñas ---------- */
@media (max-width: 860px) {
	.emg-play--scene, .emg-play--words, .emg-play--cross { grid-template-columns: 1fr; }
	.emg-play--words .emg-wsgrid { max-width: 560px; margin: 0 auto; width: 100%; }
	.emg-clues, .emg-checklist { max-width: 640px; margin: 0 auto; width: 100%; }
	.emg-play--words .emg-checklist ul { columns: 2; column-gap: 14px; }
	.emg-play--words .emg-checklist li { break-inside: avoid; }
}
.emg-tip { display: none; margin: 0 auto 10px; max-width: 980px; padding: 8px 12px; border-radius: 12px; background: #e8f3ff; color: #0e5fa6; font-weight: 700; font-size: 0.9rem; text-align: center; }
@media (max-width: 700px) and (orientation: portrait) { .emg-tip { display: block; } }
@media (max-width: 640px) {
	.emg-cards { grid-template-columns: repeat(3, 1fr); gap: 10px; }
	.emg-zones { gap: 10px; }
	.emg-item { width: 66px; height: 82px; }
	.emg-chip { width: 36px; height: 36px; }
	.emg-grid { grid-template-columns: 1fr; }
	.emg-progress { padding: 12px 14px; gap: 12px; }
	.emg-progress img { width: 52px; height: 52px; }
	.emg-howto p { font-size: 0.9rem; }
	.emg-token { width: 6%; }
}

@media (prefers-reduced-motion: reduce) {
	.emg-progress img, .emg-modal-gota, .emg-goal, .emg-hintring, .emg-found, .emg-oval, .emg-chip, .emg-modal-card, .emg-cell.is-hint { animation: none !important; }
	.emg-confetti { display: none; }
}
