@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-deep: #0B1917;
    --bg-panel: rgba(20, 43, 39, 0.94);
    --bg-panel-solid: #14302B;
    --bg-card: #1B3B34;
    --accent-gold: #E3A23C;
    --accent-gold-dark: #B87F27;
    --accent-teal: #2FA88F;
    --accent-teal-dark: #22705D;
    --text-light: #F2EFE6;
    --text-muted: #A9BAB2;
    --text-dim: #7C9089;
    --danger: #E06150;
    --success: #6FBF8B;
    --radius: 14px;
    --shadow: 0 12px 32px rgba(0,0,0,0.4);
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-light);
}

.mo-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: rgba(11, 25, 23, 0.82);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(227, 162, 60, 0.18);
}

.mo-marca { display: flex; align-items: center; gap: 10px; }

.mo-header h1 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
    letter-spacing: 0.3px;
    color: var(--text-light);
}

.mo-header a { color: var(--accent-gold); text-decoration: none; font-weight: 500; }
.mo-header a:hover { text-decoration: underline; }

.mo-usuario-info { font-size: 14px; color: var(--text-muted); display: flex; align-items: center; gap: 10px; }
.mo-usuario-info button {
    background: transparent;
    border: 1px solid var(--accent-teal);
    color: var(--accent-teal);
    border-radius: 20px;
    padding: 6px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.mo-usuario-info button:hover { background: var(--accent-teal); color: var(--bg-deep); }

.mo-panel {
    max-width: 400px;
    margin: 100px auto 40px;
    background: var(--bg-panel-solid);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(227, 162, 60, 0.12);
}

.mo-tabs { display: flex; margin-bottom: 20px; border-radius: 10px; overflow: hidden; }
.mo-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-body);
    transition: background 0.15s, color 0.15s;
}
.mo-tab.activo { background: var(--accent-teal); color: var(--bg-deep); }

.mo-form { display: flex; flex-direction: column; gap: 12px; }
.mo-form input, .mo-editor input, .mo-modal input {
    padding: 11px 14px;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 10px;
    font-size: 14px;
    background: rgba(255,255,255,0.06);
    color: var(--text-light);
    font-family: var(--font-body);
}
.mo-form input::placeholder, .mo-modal input::placeholder { color: var(--text-dim); }
.mo-form input:focus, .mo-modal input:focus { outline: none; border-color: var(--accent-gold); }

.mo-btn, .mo-form button {
    padding: 11px 20px;
    border: none;
    border-radius: 10px;
    background: var(--accent-gold);
    color: #241706;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font-body);
    transition: transform 0.1s, background 0.15s;
    box-shadow: 0 4px 12px rgba(227, 162, 60, 0.25);
}
.mo-btn:hover, .mo-form button:hover { background: #F0B454; transform: translateY(-1px); }
.mo-btn:active, .mo-form button:active { transform: translateY(0); }
.mo-btn.mo-btn-secundario {
    background: rgba(255,255,255,0.08);
    color: var(--text-light);
    box-shadow: none;
}
.mo-btn.mo-btn-secundario:hover { background: rgba(255,255,255,0.14); }

.mo-error { color: var(--danger); font-size: 13px; min-height: 16px; margin: 0; }

.mo-juego { position: fixed; inset: 0; top: 0; }
#mapa { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }

/* Le da más carácter a las tiles del mapa base, en vez del gris plano */
#mapa .leaflet-tile-pane { filter: saturate(1.25) contrast(1.04) brightness(0.98) hue-rotate(-2deg); }

/* Partículas ambiente: luciérnagas doradas flotando sobre el mapa */
.mo-ambiente { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.mo-chispa {
    position: absolute;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--accent-gold);
    box-shadow: 0 0 6px 2px rgba(227, 162, 60, 0.6);
    opacity: 0;
    animation: flotar-chispa 9s ease-in-out infinite;
}
.mo-chispa:nth-child(1) { left: 12%; top: 70%; animation-delay: 0s; }
.mo-chispa:nth-child(2) { left: 28%; top: 40%; animation-delay: 1.2s; }
.mo-chispa:nth-child(3) { left: 46%; top: 80%; animation-delay: 2.4s; }
.mo-chispa:nth-child(4) { left: 63%; top: 30%; animation-delay: 3.6s; }
.mo-chispa:nth-child(5) { left: 77%; top: 60%; animation-delay: 4.8s; }
.mo-chispa:nth-child(6) { left: 20%; top: 20%; animation-delay: 6s; }
.mo-chispa:nth-child(7) { left: 55%; top: 55%; animation-delay: 7.2s; }
.mo-chispa:nth-child(8) { left: 85%; top: 22%; animation-delay: 8.4s; }
@keyframes flotar-chispa {
    0%   { opacity: 0; transform: translateY(0) scale(0.8); }
    15%  { opacity: 0.9; }
    50%  { opacity: 0.5; transform: translateY(-22px) scale(1.1); }
    85%  { opacity: 0.9; }
    100% { opacity: 0; transform: translateY(-42px) scale(0.8); }
}
@media (prefers-reduced-motion: reduce) {
    .mo-chispa { animation: none; opacity: 0.4; }
}

/* Marcador de misión: pin dorado con rebote al aparecer e idle flotante */
.pin-mision {
    width: 34px; height: 44px;
    transform-origin: bottom center;
    animation: aparecer-pin 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both, flotar-pin 2.6s ease-in-out infinite 0.5s;
    cursor: pointer;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.45));
}
.pin-mision:hover { animation-play-state: paused; transform: scale(1.12); }
@keyframes aparecer-pin {
    0%   { transform: scale(0) translateY(10px); opacity: 0; }
    70%  { transform: scale(1.15) translateY(0); opacity: 1; }
    100% { transform: scale(1) translateY(0); }
}
@keyframes flotar-pin {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
    .pin-mision { animation: none; }
}

#btn-proponer-lugar {
    width: 100%;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 14px;
    font-size: 14px;
    flex-shrink: 0;
}
#aviso-colocar {
    margin: 0;
    padding: 10px 16px;
    background: rgba(227, 162, 60, 0.12);
    color: var(--accent-gold);
    font-size: 13px;
    border-top: 1px solid rgba(227, 162, 60, 0.18);
    flex-shrink: 0;
}

.mo-dock {
    position: fixed;
    top: 84px;
    left: 20px;
    z-index: 500;
    width: 280px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(227, 162, 60, 0.14);
    overflow: hidden;
}
.mo-dock-tabs { display: flex; align-items: stretch; border-bottom: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; }
.mo-dock-tab {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    border-bottom: 2px solid transparent;
}
.mo-dock-tab.activo { color: var(--accent-gold); border-bottom-color: var(--accent-gold); }
#btn-dock-toggle {
    flex: 0 0 auto;
    width: 36px;
    background: none;
    border: none;
    border-left: 1px solid rgba(255,255,255,0.08);
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
}
#btn-dock-toggle:hover { color: var(--accent-gold); }
.mo-dock.colapsado .mo-dock-contenido,
.mo-dock.colapsado #aviso-colocar,
.mo-dock.colapsado #btn-proponer-lugar { display: none; }
.mo-dock-contenido { padding: 16px; overflow-y: auto; flex-shrink: 1; }
.mo-dock-seccion { display: none; }
.mo-dock-seccion.activo { display: block; }

/* Control de zoom de Leaflet, con el mismo lenguaje visual */
.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a {
    background: var(--bg-panel-solid) !important;
    color: var(--text-light) !important;
    border-color: rgba(255,255,255,0.1) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-card) !important; color: var(--accent-gold) !important; }

.mo-fila-ranking {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 13px;
    color: var(--text-light);
}
.mo-fila-ranking:last-child { border-bottom: none; }

.mo-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 13, 12, 0.65);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.mo-modal {
    background: var(--bg-panel-solid);
    border-radius: 18px;
    padding: 24px;
    width: 90%;
    max-width: 420px;
    position: relative;
    box-shadow: var(--shadow);
    border: 1px solid rgba(227, 162, 60, 0.16);
    animation: aparecer-modal 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes aparecer-modal {
    0%   { transform: scale(0.9) translateY(12px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .mo-modal { animation: none; }
}
.mo-modal h3 {
    font-family: var(--font-display);
    font-size: 19px;
    margin: 0 0 14px;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 8px;
}
.mo-modal-icono { display: inline-flex; color: var(--accent-gold); flex-shrink: 0; }
.mo-modal-cerrar {
    position: absolute;
    top: 14px;
    right: 16px;
    border: none;
    background: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
}
.mo-modal-cerrar:hover { color: var(--text-light); }
.mo-modal input[type="text"] { width: 100%; margin: 0 0 10px; }
.mo-feedback { font-size: 13px; margin-top: 8px; min-height: 18px; }
.mo-feedback.ok { color: var(--success); }
.mo-feedback.error { color: var(--danger); }

.mo-estrella { color: var(--accent-gold); }

.mo-nivel-nombre { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin: 0 0 4px; color: var(--text-light); }
.mo-nivel-sub { font-size: 12px; color: var(--text-dim); margin: 0 0 10px; }
.mo-barra-fondo { background: rgba(255,255,255,0.08); border-radius: 6px; height: 8px; overflow: hidden; }
.mo-barra-relleno { background: linear-gradient(90deg, var(--accent-gold-dark), var(--accent-gold)); height: 100%; }

.mo-insignias { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.mo-insignia {
    background: rgba(227, 162, 60, 0.12);
    color: var(--accent-gold);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: default;
    border: 1px solid rgba(227, 162, 60, 0.2);
}
.mo-insignia-vacia { font-size: 12px; color: var(--text-dim); }

.mo-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: var(--text-dim);
    background: rgba(11, 25, 23, 0.6);
    z-index: 400;
    pointer-events: none;
}

.pin-oculto {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--accent-gold);
    border: 2px solid var(--bg-deep);
}

.mo-pendiente {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(255,255,255,0.06);
}
.mo-pendiente p { margin: 4px 0; font-size: 14px; color: var(--text-light); }
.mo-pendiente .mo-meta { color: var(--text-dim); font-size: 12px; }
.mo-pendiente a { color: var(--accent-teal); }
.mo-acciones { display: flex; gap: 8px; margin-top: 10px; }
.mo-acciones button { padding: 8px 14px; border: none; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; }
.btn-aprobar { background: var(--accent-teal); color: #06231d; }
.btn-rechazar { background: var(--danger); color: #2b0904; }

.mo-editor { display: flex; gap: 16px; max-width: 1100px; margin: 100px auto 40px; padding: 0 16px; }
.mo-editor-mapa { flex: 3; }
#mapa-editor { height: 560px; border-radius: var(--radius); overflow: hidden; }
.mo-editor-lista { flex: 1; min-width: 220px; }
.mo-lugar-fila { padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; cursor: pointer; color: var(--text-light); }
.mo-lugar-fila:hover { background: rgba(255,255,255,0.04); }
.mo-coords { font-size: 11px; color: var(--text-dim); }

/* ===== Decoración de borde: puramente ambiental, nunca interactiva ===== */

/* Banderines de colores, esquina superior derecha */
.mo-banderines {
    position: fixed;
    top: 64px;
    right: 16px;
    width: 160px;
    height: 44px;
    z-index: 300;
    pointer-events: none;
}
.bandera polygon { transform-origin: top center; animation: ondear-bandera 2.6s ease-in-out infinite; }
.b1 polygon { fill: var(--accent-gold); animation-delay: 0s; }
.b2 polygon { fill: var(--accent-teal); animation-delay: 0.15s; }
.b3 polygon { fill: var(--danger); animation-delay: 0.3s; }
.b4 polygon { fill: var(--accent-gold); animation-delay: 0.45s; }
.b5 polygon { fill: var(--accent-teal); animation-delay: 0.6s; }
.b6 polygon { fill: var(--danger); animation-delay: 0.75s; }
@keyframes ondear-bandera {
    0%, 100% { transform: rotate(-6deg); }
    50%      { transform: rotate(6deg); }
}

/* Cartel que va cambiando frases de aliento */
.mo-cartel-animo {
    position: fixed;
    top: 116px;
    right: 16px;
    z-index: 300;
    background: var(--bg-panel-solid);
    border: 1px solid rgba(227, 162, 60, 0.25);
    color: var(--accent-gold);
    font-family: var(--font-display);
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    pointer-events: none;
    animation: mecer-cartel 4s ease-in-out infinite;
    transition: opacity 0.5s;
}
@keyframes mecer-cartel {
    0%, 100% { transform: rotate(-1.5deg); }
    50%      { transform: rotate(1.5deg); }
}

/* Personaje que aparece a saludar, esquina inferior derecha */
.mo-personaje {
    position: fixed;
    bottom: 70px;
    right: 24px;
    width: 52px;
    height: 60px;
    z-index: 300;
    pointer-events: none;
    animation: asomar-personaje 9s ease-in-out infinite;
}
.brazo-saluda { transform-origin: 40px 40px; animation: saludar-brazo 0.5s ease-in-out infinite alternate; }
@keyframes saludar-brazo {
    from { transform: rotate(-10deg); }
    to   { transform: rotate(28deg); }
}
@keyframes asomar-personaje {
    0%, 55%  { transform: translateY(100%); opacity: 0; }
    65%, 90% { transform: translateY(0); opacity: 1; }
    100%     { transform: translateY(100%); opacity: 0; }
}

/* Franja de skyline animada, todo el ancho, sobre el footer */
.mo-skyline {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 250;
    pointer-events: none;
    opacity: 0.9;
}
.arbol { animation: crecer-arbol 3.2s ease-in-out infinite; }
@keyframes crecer-arbol {
    0%, 100% { transform: scaleY(0.92); }
    50%      { transform: scaleY(1); }
}
.bandera-mastil { transform-origin: 436px 78px; animation: ondear-bandera 2.2s ease-in-out infinite; }
.humo circle {
    fill: rgba(242, 239, 230, 0.4);
    animation: subir-humo 2.6s ease-out infinite;
}
@keyframes subir-humo {
    0%   { opacity: 0; transform: translateY(0) scale(0.6); }
    30%  { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(-18px) scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
    .bandera polygon, .mo-cartel-animo, .mo-personaje, .brazo-saluda,
    .arbol, .bandera-mastil, .humo circle { animation: none; }
    .mo-personaje { opacity: 0; }
}

/* En celular, ocultamos la decoración de borde para no restar espacio útil */
@media (max-width: 640px) {
    .mo-banderines, .mo-cartel-animo, .mo-personaje { display: none; }
    .mo-skyline { height: 34px; }
}

/* Responsivo: tablets */
@media (max-width: 900px) {
    .mo-editor { flex-direction: column; }
    .mo-editor-mapa { width: 100%; }
}

/* Responsivo: celulares */
@media (max-width: 640px) {
    .mo-header { padding: 10px 14px; }
    .mo-header h1 { font-size: 18px; }
    .mo-usuario-info { font-size: 12px; gap: 6px; }
    .mo-usuario-info button { padding: 5px 12px; font-size: 12px; }

    .mo-panel { margin: 78px 12px 24px; padding: 20px; max-width: none; }

    .mo-dock {
        top: 64px;
        left: 10px;
        right: 10px;
        width: auto;
        max-height: 60vh;
    }
    .mo-dock-tab { font-size: 11px; padding: 10px 4px; }
    .mo-dock-contenido { padding: 12px; max-height: 32vh; }

    #btn-proponer-lugar { padding: 12px; font-size: 13px; }
    #aviso-colocar { font-size: 12px; padding: 8px 12px; }

    .mo-modal { padding: 18px; width: 92%; }
    .mo-modal h3 { font-size: 17px; }

    .mo-footer { font-size: 10px; padding: 6px; }

    .mo-editor { margin-top: 78px; padding: 0 10px; }
    #mapa-editor { height: 360px; }
}

/* Pantallas muy chicas: ocultar el saludo, dejar solo el botón de salir */
@media (max-width: 380px) {
    .mo-usuario-info span { display: none; }
}
